#P17269. [ICPC 2017 Urumqi R] Sum of the Line
[ICPC 2017 Urumqi R] Sum of the Line
Problem Description
Consider a triangle of integers, denoted by . The value at is denoted by , where and . If the greatest common divisor of and is exactly , , or otherwise.
Now, we have another triangle of integers, denoted by . The value at is denoted by , where and . is defined as the summation .
Here comes your turn. For given positive integer , you need to calculate the summation of elements in -th row of the triangle .
Input Format
The first line of input contains an integer which is the number of test cases. Each test case includes a single line with an integer described as above satisfying .
Output Format
For each case, calculate the summation of elements in the -th row of , and output the remainder when it divided by .
2
2
3
1
5