Rikka with Equation

m이 n 이하일 때 x^2+y^2≡a, xy≡b (mod m)를 만족하는 정수 x, y가 존재하는 (a,b,m)의 개수를 센다.

어려움9정수론수학동적 계획법아직 제출이 없습니다시간 제한2초메모리 제한512 MB

문제

The conclusion of Hilbert's tenth problem shows that it is impossible to design an algorithm to find all integer solutions of an arbitrary system of equations. But for some simple equations, is is still easily doable.

For example, how do we check if there exist two integers xx and yy which satisfy x2+y2=ax^2 + y^2 = a and xy=bx y = b? We can calculate x+y=±a+2bx + y = \pm \sqrt{a + 2b} and xy=±a2bx - y = \pm \sqrt{a - 2b}, and then check if both xx and yy could be integers.

Rikka thinks this task is too simple, and she wants to make it look harder. Rikka knows that sometimes, if you consider an equality modulo mm, the problem becomes different. So, she wants to do the same thing to this problem.

Let us call a tuple (a,b,m)(a, b, m) (0a,b<m0 \leq a, b < m) valid if and only if there exist two integers xx and yy which satisfy x2+y2a(modm)x^2 + y^2 \equiv a \pmod{m} and xyb(modm)x y \equiv b \pmod{m}. After giving you a positive integer nn, Rikka wants you to calculate the number of valid tuples (a,b,m)(a, b, m) with mnm \leq n. As this number may be rather large, calculate it modulo 998,244,353998\\,244\\,353.

입력

The first line contains a single integer tt (1t1051 \leq t \leq 10^5), the number of test cases.

Each test case is given on a separate line containing a single integer nn (1n1071 \leq n \leq 10^7).

출력

For each test case, output a single line with a single integer: the number of valid tuples modulo 998,244,353998\\,244\\,353.