#P5746. [NOI2002] 机器人M号

[NOI2002] 机器人M号

Description

In the year 3030, Macsy is deploying a batch of robots on Mars.

At the 11st second, he shipped robot No. 11 to Mars. Robot No. 11 can manufacture other robots.

At the 22nd second, robot No. 11 built the first robot—robot No. 22.

At the 33rd second, robot No. 11 built another robot—robot No. 33.

After that, every second, robot No. 11 can build one new robot. The robot built at the mm-th second has index mm. We call it robot No. mm, or the mm-th robot.

After a robot is built, it starts working immediately. Robot No. mm rests once every mm seconds. For example, robot No. 33 rests at the 66th, 99th, 1212th, \ldots seconds, and works at all other times.

When a robot rests, its memory will be transplanted into the brain of the robot born at that moment. For example, when robot No. 66 is born, robots No. 22 and No. 33 are resting, so robot No. 66 receives copies of the memories of robots No. 22 and No. 33. We call robots No. 22 and No. 33 the teachers of robot No. 66.

If two robots do not have a teacher-student relationship, and they do not share any common teacher, then we say the knowledge of these two robots is mutually independent. Note: the knowledge of robot No. 11 is independent of all other robots (because only robot No. 11 builds robots), and it is not any robot’s teacher.

The independence number of a robot is the number of robots with smaller indices whose knowledge is mutually independent from it. For example, the independence number of robot No. 11 is 00; the independence number of robot No. 22 is 11 (robot No. 11 is mutually independent from it); the independence number of robot No. 66 is 22 (robots No. 11 and No. 55 are mutually independent from it; robots No. 22 and No. 33 are its teachers; and robot No. 44 shares a common teacher—robot No. 22—with it).

Newly built robots have 33 different professions. For a robot with index mm, if mm can be factored into a product of an even number of distinct odd primes, then it is a politician, for example index 1515; otherwise, if mm itself is an odd prime, or mm can be factored into a product of an odd number of distinct odd primes, then it is a soldier, for example index 33 and index 165165. Robots with other indices are scholars, for example index 22, index 66, and index 99.

Robot No. mm, born at the mm-th second, wants to know: among itself and its teachers, the sum of the independence numbers of all politicians, the sum of the independence numbers of all soldiers, and the sum of the independence numbers of all scholars. But robot No. mm is busy working and has no time to compute. Can you help it?

To make computation easier, Macsy has already factored mm into primes for you. To make output easier, you only need to output the remainder after dividing each sum by 1000010000.

Input Format

The first line contains a positive integer kk, where kk is the number of distinct prime factors of mm.

The next kk lines each contain two integers pip_i, eie_i, representing the ii-th prime factor of mm and its exponent (i=1,2,,k)(i=1,2,\ldots,k). p1,p2,,pkp_1,p_2,\ldots,p_k are distinct primes, and m=i=1kpieim=\prod_{i=1}^k p_i^{e_i}. All prime factors are given in increasing order, i.e. p1<p2<<pkp_1<p_2<\ldots<p_k.

Output Format

Output consists of three lines.

  • The first line is the remainder after dividing by 1000010000 the sum of the independence numbers of all politicians among robot No. mm and its teachers.
  • The second line is the remainder after dividing by 1000010000 the sum of the independence numbers of all soldiers among robot No. mm and its teachers.
  • The third line is the remainder after dividing by 1000010000 the sum of the independence numbers of all scholars among robot No. mm and its teachers.
3
2 1
3 2
5 1
8
6
75

Hint

Sample Explanation

m=2×32×5=90m = 2\times 3^2\times 5=90. Robot No. 9090 has 1010 teachers; together with itself there are 1111 robots. Among them, the only politician is robot No. 1515; the soldiers are robot No. 33 and robot No. 55; there are 88 scholars, with indices: 2,6,9,10,18,30,45,902,6,9,10,18,30,45,90.

Constraints

For all testdata, 1k10001\le k\le 1000, 2pi<10,0002\le p_i<10,000, 1ei1,000,0001\le e_i\le 1,000,000.

Scoring Rules

Your score on a test point depends on the number of subproblems you solve correctly, denoted by xx.

Please note: for each line, even if you cannot solve that part, you must still output a number on that line; otherwise the checker cannot score correctly.

xx Score
3 10
2 7
1 4
0

Translated by ChatGPT 5