Company: OYO
Difficulty: medium
Fruit Stall Step Queries A fruit stall keeps N varieties of fruit in a row, numbered 1 to N from left to right, and the variety at position i has price val[i] . You must process Q operations. Each operation is described by three integers type , X and Y , and designates a set of positions: the fruit at position X is always designated, and every further fruit whose position differs from X by an exact positive multiple of Y is designated too. In other words the designated positions are X , X + Y , X + 2Y , X + 3Y , ... , taken only while the position is at most N . 0 X Y — report the sum of the prices of all designated fruits. 1 X Y — report the product of the prices of all designated fruits. Because the results can be very large, every reported answer must be given modulo 1000000007 . The input contains several independent test cases. Read the input from STDIN and print the output to STDOUT. Do not print anything other than the required answers. Input Format The first line contains a sin