Given a number $n$, give the last digit of sum of all the prime numbers from 1 to $n$ inclusive.
-----Input:-----
- First line contains number of testcase $t$.
- Each testcase contains of a single line of input, number $n$. 
-----Output:-----
Last digit of sum of every prime number till n.
-----Constraints-----
- $1 \leq T \leq 10$
- $2 \leq N \leq 10^6$
-----Sample Input:-----
1
10
-----Sample Output:-----
7

def sumOfPrimes(n): 

	prime = [True] * (n + 1) 

	
	p = 2
	while p * p <= n: 

		if prime[p] == True: 

			i = p * 2
			while i <= n: 
				prime[i] = False
				i += p 
		p += 1	

	sum = 0
	for i in range (2, n + 1): 
		if(prime[i]): 
			sum += i 
	return sum

for _ in range(int(input())):
    n = int(input())
    zzz = str(sumOfPrimes(n))
    print(zzz[-1])

def sumOfPrimes(n): 

	prime = [True] * (n + 1) 

	
	p = 2
	while p * p <= n: 

		if prime[p] == True: 

			i = p * 2
			while i <= n: 
				prime[i] = False
				i += p 
		p += 1	

	sum = 0
	for i in range (2, n + 1): 
		if(prime[i]): 
			sum += i 
	return sum

for _ in range(int(input())):
    n = int(input())
    zzz = str(sumOfPrimes(n))
    print(zzz[-1])