logo AlgoBeat OnlineJudge
登录 注册

#217142. [ICPC 2017 Urumqi R] Sum of the Line

内存限制:512 MiB 时间限制:1000 ms 标准输入输出
题目类型:VJudge(洛谷) 评测方式:VJudge
上传者: 匿名

题目描述

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 .

输入格式

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 .

输出格式

For each case, calculate the summation of elements in the -th row of , and output the remainder when it divided by .

样例

样例输入 1

2
2
3

样例输出 1

1
5