eolymp
bolt
Try our new interface for solving problems
Problems

DeviantArt

DeviantArt

The art of photography is another Ira's hobby. Her works occupy a worthy place on the pages of DeviantArt. Every Internet user can freely go to her gallery and "Like" image(s) he liked, increasing rating of those image(s) by \textbf{1}. --- \textit{Mmm! Not a bad job for a bot}. The essence of the bot consisted in the following: a specially created user "Likes" \textbf{K} photos, starting with \textbf{I}-th, in increments of \textbf{A}. The second bot was created to monitor results. It checks the sum of ratings for \textbf{L} pictures, starting with \textbf{J}-th, in increments of \textbf{B}. Photographs are numbered from \textbf{0}. Bots work independently until the administration of DeviantArt will notice the cheating with "Likes" and bans both Anonymouses. \InputFile First line of input file contains four integers \textbf{N} (\textbf{1} ≤ \textbf{N} ≤ \textbf{10^5}), \textbf{A} (\textbf{1} ≤ \textbf{A} ≤ \textbf{N}), \textbf{B} (\textbf{1} ≤ \textbf{B} ≤ \textbf{N}) and \textbf{Q} (\textbf{0} ≤ \textbf{Q} ≤ \textbf{10^5}) --- number of pictures, size of steps for bots that do not change throughout their lives, and the total number of iterations, respectively. Then in each of \textbf{Q} of lines written a command for a bot: \textbf{s I K} --- first bot "Likes" \textbf{K} (\textbf{1} ≤ \textbf{K} ≤ \textbf{N},\textbf{ I+(K-1)A }≤\textbf{ N-1}) pictures, starting from \textbf{I}-th (\textbf{0} ≤ \textbf{I} ≤ \textbf{N-1}). \textbf{g J L} --- second bot counts rating of \textbf{L} (\textbf{1} ≤ \textbf{L} ≤ \textbf{N}, \textbf{J+(L-1)B }≤\textbf{ N-1}) pictures, starting from \textbf{J}-th (\textbf{0} ≤ \textbf{J} ≤ \textbf{N-1}). Before bots started their actions, all pictures had rating \textbf{0}. \OutputFile In a separate line print a result for each command for second bot.
Time limit 1 second
Memory limit 64 MiB