MySpace
Situation similar to the one in the problem DeviantArt, occured on MySpace website.
Briey, two bots had to increase photos rating - Each "Like" on the picture increases its rating by 1. First bot "Likes" all the photos with numbers K such that K mod A = I. The second bot counts the rating of all the pictures with numbers L such that L mod B = J. Pictures are enumerated starting from 0.
Input
Four number N, A, B and Q (1 ≤ N ≤ 10^5, 1 ≤ A ≤ N, 1 ≤ B ≤ N, 0 ≤ Q ≤ 10^5) re given in the rst line - number of the photos, bot step values, which don't change during their life, and total number of iterations. In every next lines command for the bot is written:
s I — first bot "Likes" photos I, I+A, I+2A, I+3A, ... (0 ≤ I < A).
g J — second bot sums "Likes" of photos J, J+B, J+2B, J+3B, ... (0 ≤ J < B).
Before bots start their activity, all photos had rating 0.
Output
For every command of the second bot, print its result on a separate line.