Under construction

Still being built. Things may change

Rikka with Equation

Time limit2sMemory limit512 MB

Summary
For each n, count tuples (a, b, m) with m at most n such that some integers x and y satisfy x^2 + y^2 is congruent to a and xy is congruent to b modulo m.
Level

Hard9 of 10

Topics
Math, Number theory
Solved
No attempts yet

Problem

The conclusion of Hilbert's tenth problem shows that no algorithm can find all integer solutions of an arbitrary system of equations. However, some simple equations are still easily solvable.

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

Rikka thinks this task is too simple, so she wants to make it look harder. Rikka knows that sometimes considering an equation modulo mm makes the problem different. So she wants to do the same with this problem.

A tuple (a,b,m)(a, b, m) with 0≤a,b<m0 \leq a, b < m is valid if and only if there exist two integers xx and yy that satisfy x2+y2≡a(modm)x^2 + y^2 \equiv a \pmod{m} and xy≡b(modm)xy \equiv b \pmod{m}. Given a positive integer nn, count the number of valid tuples (a,b,m)(a, b, m) with m≤nm \leq n. Since this number may be large, output it modulo 998 244 353998\,244\,353.

Input

The first line contains a single integer tt (1≤t≤1051 \leq t \leq 10^5), the number of test cases. Each test case is given on a separate line containing a single integer nn (1≤n≤1071 \leq n \leq 10^7).

Output

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

Examples1

  1. Example 1

    Input
    5
    3
    5
    10
    100
    1000
    
    Expected output
    8
    22
    104
    45933
    32791150