Lines in a grid

아직 제출이 없습니다시간 제한8초메모리 제한1024 MB

문제

Suppose that we are given a n×nn × n integer grid, e.g. (i,j)_i=0,j=0n1,n1\\{(i, j)\\}\_{i=0, j=0}^{n-1, n-1}. Let l_nl\_n be the number of different lines that intersect with at least two points on the grid.

For n=3n = 3, there are exactly 2020 such lines, as drawn on the image below.

Compute l_nl\_n for all given nn.

입력

First line contains an integer QQ – the number of queries. The second line contains QQ space-separated integers n_1,,n_Qn\_1, \dots , n\_Q.

출력

Print QQ numbers l_n_1,,l_n_Nl\_{n\_1} , \dots , l\_{n\_N}, each in its own line. Since l_kl\_k can be large, print them modulo 106+310^6 + 3.

제한

  • 1Q10001 ≤ Q ≤ 1000
  • 1n_i1071 ≤ n\_i ≤ 10^7