#P11772. 报社天狗

    ID: 11163 远端评测题 4000ms 512MiB 尝试: 0 已通过: 0 难度: 8 上传者: 标签>数论洛谷原创O2优化分块洛谷月赛整除分块

报社天狗

Description

New issue of Bunbunmaru Newspaper is on sale!

nn youkais numbered 11 to nn waits in a line buying the newspaper. Each of them may buy multiple pieces, one single piece or none, depending on their goal — Instead of buying to read, they buy the newspaper to share. One will give a piece of newspaper to everyone whose ID is a multiple of her own ID, even without leaving herself one piece. Youkais numbered 11 to nn will follow this process in sequence: If the number of newspaper pieces she have is sufficient, she will proceed directly to the giveaway. If not, she will purchase the exact number of newspapers needed before completing the giveaway.

To maximize her profit, Syameimaru Aya, the writer of Bunbunmaru Newspaper, is planning to make a pricing scheme. The scheme is described by two 1-indexed arrays of positive integers a,ba,b, which have a length of 106+110^6+1 each. When a youkai with ID ii holding jj pieces of newspaper buy one another piece of newspaper, she should pay ai×bj+1a_i\times b_{j+1} yen.

Now Aya needs a fair pricing scheme. She chose to begin adjusting the sequences starting when all elements in aa and bb are initialized to 11. And then there's three types of TT operations:

  • 1 x Aya asks you how much revenue she can make in the current state of sequences aa and bb. Since the answer could be too large, you should output the answer mod 232\bmod~ 2^{32}.

  • 2 x y Aya changes the xx-th element of array aa to yy.

  • 3 x y Aya changes the xx-th element of array bb to yy.

Can you answer all of her questions?

Input Format

The first line of input contains an integer TT — the amount of operations.

The following TT rows each contain 22 or 33 integers, representing an operation as described in the problem.

Output Format

For each operation of the first type, print the answer, modulo 2^{32.

5
1 5
2 2 5
3 1 3
1 5
1 6
4
6
12

Hint

Sample Explanation

In the first question, n=5n=5, all the elements in two arrays equal to 11. the youkai with ID 11 need to buy 44 pieces of newspaper and cost 11 yen for each piece. Other youkais don't need to buy any newspaper. the revenue in total will be 44 yen.

In the second question, n=5,a2=5,b1=3n=5,a_2=5,b_1=3, other elements in two arrays equal to 11. the youkai with ID 11 need to buy 44 pieces of newspaper and cost 33 yen for the first piece, 11 yen for the other pieces. Other youkais don't need to buy any newspaper. the revenue in total will be 66 yen.

In the third question, n=6,a2=5,b1=3n=6,a_2=5,b_1=3, other elements in two arrays equal to 11. Let's check out the details in this question:

  • The youkai with ID 11 needs to give other youkais one pieces of newspaper each, but she has none, so she needs to buy 55 pieces of newspaper. the first piece costs a1×b1=3a_1\times b_1=3 yen and the others cost 11 yen each.

  • The youkai with ID 22 needs to give youkais with ID 44 or 66 one pieces of newspaper each. She has got a piece from the youkai with ID 11, so she needs to buy 11 piece of newspaper which costs a2×b1=5a_2\times b_1=5 yen.

  • The youkai with ID 33 needs to give youkai with ID 66 one piece of newspaper, she has got a piece from the youkai with ID 11, so she doesn't need to buy newspaper.

  • the youkais with ID 4,5,64,5,6 don't need to give out newspaper, so they doesn't need to buy newspaper.

the revenue in total will be 1212 yen.

Constraints

Subtasks applied. You can only gain the score of the subtask if you accepted all the tests in the subtask.

Subtask ID Special Property Score
11 No modification operations exist 1010
22 nn in every operation of first type is same 2020
33 n,T105n,T \leq 10^5 3030
44 - 4040

For all tests, it is guaranteed that 1T1061 \leq T \leq 10^61x,n1051 \leq x,n\leq 10^5.