#P1792E. Divisors and Table

    ID: 251 Type: RemoteJudge 2000ms 256MiB Tried: 0 Accepted: 0 Difficulty: 9 Uploaded By: Tags>brute forcedfs and similardpnumber theory*2400

Divisors and Table

Description

You are given an n×nn \times n multiplication table and a positive integer m=m1m2m = m_1 \cdot m_2. A n×nn \times n multiplication table is a table with nn rows and nn columns numbered from 11 to nn, where ai,j=ija_{i, j} = i \cdot j.

For each divisor dd of mm, check: does dd occur in the table at least once, and if it does, what is the minimum row that contains dd.

The first line contains a single integer tt (1t101 \le t \le 10) — the number of test cases.

The first and only line of each test case contains three integers nn, m1m_1 and m2m_2 (1n1091 \le n \le 10^9; 1m1,m21091 \le m_1, m_2 \le 10^9) — the size of the multiplication table and the integer mm represented as m1m2m_1 \cdot m_2.

For each test case, let d1,d2,,dkd_1, d_2, \dots, d_k be all divisors of mm sorted in the increasing order. And let a1,a2,,aka_1, a_2, \dots, a_k be an array of answers, where aia_i is equal to the minimum row index where divisor did_i occurs, or 00, if there is no such row.

Since array aa may be large, first, print an integer ss — the number of divisors of mm that are present in the n×nn \times n table. Next, print a single value X=a1a2akX = a_1 \oplus a_2 \oplus \dots \oplus a_k, where \oplus denotes the bitwise XOR operation.

Input

The first line contains a single integer tt (1t101 \le t \le 10) — the number of test cases.

The first and only line of each test case contains three integers nn, m1m_1 and m2m_2 (1n1091 \le n \le 10^9; 1m1,m21091 \le m_1, m_2 \le 10^9) — the size of the multiplication table and the integer mm represented as m1m2m_1 \cdot m_2.

Output

For each test case, let d1,d2,,dkd_1, d_2, \dots, d_k be all divisors of mm sorted in the increasing order. And let a1,a2,,aka_1, a_2, \dots, a_k be an array of answers, where aia_i is equal to the minimum row index where divisor did_i occurs, or 00, if there is no such row.

Since array aa may be large, first, print an integer ss — the number of divisors of mm that are present in the n×nn \times n table. Next, print a single value X=a1a2akX = a_1 \oplus a_2 \oplus \dots \oplus a_k, where \oplus denotes the bitwise XOR operation.

Sample Input 1

3
3 72 1
10 10 15
6 1 210

Sample Output 1

6 2
10 0
8 5

Note

In the first test case, m=721=72m = 72 \cdot 1 = 72 and has 1212 divisors [1,2,3,4,6,8,9,12,18,24,36,72][1, 2, 3, 4, 6, 8, 9, 12, 18, 24, 36, 72]. The 3×33 \times 3 multiplication table looks like that:

123
1123
2246
3369

For each divisor of mm that is present in the table, the position with minimum row index is marked. So the array of answers aa is equal to [1,1,1,2,2,0,3,0,0,0,0,0][1, 1, 1, 2, 2, 0, 3, 0, 0, 0, 0, 0]. There are only 66 non-zero values, and xor of aa is equal to 22.

In the second test case, m=1015=150m = 10 \cdot 15 = 150 and has 1212 divisors [1,2,3,5,6,10,15,25,30,50,75,150][1, 2, 3, 5, 6, 10, 15, 25, 30, 50, 75, 150]. All divisors except 7575 and 150150 are present in the 10×1010 \times 10 table. Array aa == [1,1,1,1,1,1,3,5,3,5,0,0][1, 1, 1, 1, 1, 1, 3, 5, 3, 5, 0, 0]. There are 1010 non-zero values, and xor of aa is equal to 00.

In the third test case, m=1210=210m = 1 \cdot 210 = 210 and has 1616 divisors [1,2,3,5,6,7,10,14,15,21,30,35,42,70,105,210][1, 2, 3, 5, 6, 7, 10, 14, 15, 21, 30, 35, 42, 70, 105, 210]. The 6×66 \times 6 table with marked divisors is shown below:

123456
1123456
224681012
3369121518
44812162024
551015202530
661218243036

Array aa == [1,1,1,1,1,0,2,0,3,0,5,0,0,0,0,0][1, 1, 1, 1, 1, 0, 2, 0, 3, 0, 5, 0, 0, 0, 0, 0]. There are 88 non-zero values, and xor of aa is equal to 55.