eolymp
bolt
Try our new interface for solving problems
Problems

MySpace

MySpace

Situation similar to the one in the problem \href{/problems/2848}{DeviantArt}, occured on MySpace website. Briey, two bots had to increase photos rating - Each "Like" on the picture increases its rating by \textbf{1}. First bot "Likes" all the photos with numbers \textbf{K} such that \textbf{K mod A = I}. The second bot counts the rating of all the pictures with numbers \textbf{L} such that \textbf{L mod B = J}. Pictures are enumerated starting from \textbf{0}. \InputFile Four number \textbf{N}, \textbf{A}, \textbf{B} and \textbf{Q} (\textbf{1} ≤ \textbf{N} ≤ \textbf{10^5}, \textbf{1} ≤ \textbf{A} ≤ \textbf{N}, \textbf{1} ≤ \textbf{B} ≤ \textbf{N}, \textbf{0} ≤ \textbf{Q} ≤ \textbf{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: \begin{itemize} \item \textbf{s I} --- first bot "Likes" photos \textbf{I}, \textbf{I+A}, \textbf{I+2A}, \textbf{I+3A}, ... (\textbf{0} ≤ \textbf{I} < \textbf{A}). \item \textbf{g J} --- second bot sums "Likes" of photos \textbf{J}, \textbf{J+B}, \textbf{J+2B}, \textbf{J+3B}, ... (\textbf{0} ≤ \textbf{J} < \textbf{B}). \end{itemize} Before bots start their activity, all photos had rating \textbf{0}. \OutputFile For every command of the second bot, print its result on a separate line.
Time limit 1 second
Memory limit 256 MiB
Input example #1
10 2 5 7
s 0
g 0
g 1
g 2
s 1
g 3
g 4
Output example #1
1
1
1
2
2