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

Difficulty: UNKNOWN_DIFFICULTY

Solutions:
import math
N = 10 ** 6
sum_arr = [0] * (N + 1)

def lprime():
	arr = [0] * (N + 1)
	arr[0] = 1
	arr[1] = 1
	for i in range(2, math.ceil(math.sqrt(N) + 1)):
		if arr[i] == 0:
			for j in range(i * i, N + 1, i):
				arr[j] = 1
	curr_prime_sum = 0
	for i in range(1, N + 1):
		if arr[i] == 0:
			curr_prime_sum += i
		sum_arr[i] = curr_prime_sum
n = int(input())
lprime()
for _ in range(n):
	x = int(input())
	print(sum_arr[x] % 10)


for _ in range(int(input())):
	n = int(input())
	prime = [True for __ in range(n + 1)]
	prime[:2] = [False, False]
	total = 0
	for i in range(2, n + 1):
		if prime[i] is True:
			temp = i * 2
			total += i
			while temp <= n:
				prime[temp] = False
				temp += i
	print(str(total)[-1])


def primalsum(n):
	prime = [True] * (n + 1)
	p = 2
	sum_ = 0
	while p ** 2 <= n:
		if prime[p] == True:
			i = p * 2
			while i <= n:
				prime[i] = False
				i += p
		p += 1
	for i in range(2, n + 1):
		if prime[i]:
			sum_ += i
	return sum_
for _ in range(int(input())):
	N = int(input())
	print(str(primalsum(N))[-1])


t = int(input())
for i in range(t):
	sum1 = 0
	n = int(input())
	prime = [True for i in range(n + 1)]
	p = 2
	while p * p <= n:
		if prime[p] == True:
			for i in range(p * 2, n + 1, p):
				prime[i] = False
		p += 1
	prime[0] = False
	prime[1] = False
	for p in range(n + 1):
		if prime[p]:
			sum1 += p
	print(sum1 % 10)


def SieveOfEratosthenes(n):
	prime = [True for i in range(n + 1)]
	ans = []
	p = 2
	while p * p <= n:
		if prime[p] == True:
			for i in range(p * p, n + 1, p):
				prime[i] = False
		p += 1
	for p in range(2, n + 1):
		if prime[p]:
			ans.append(p)
	return ans
p = SieveOfEratosthenes(10 ** 6 + 10)
for _ in range(int(input())):
	n = int(input())
	s = 0
	for i in range(len(p)):
		if p[i] > n:
			break
		else:
			s += p[i]
	print(s % 10)


def sieve(n):
	prime = [True for i in range(n + 1)]
	p = 2
	while p * p <= n:
		if prime[p] == True:
			for i in range(p * p, n + 1, p):
				prime[i] = False
		p += 1
	return prime
for u in range(int(input())):
	n = int(input())
	p = sieve(n)
	s = 0
	for i in range(2, n + 1):
		if p[i] == True:
			s += i
	r = str(s)
	print(r[-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
t = int(input())
for i in range(t):
	n = int(input())
	print(sumOfPrimes(n) % 10)


def main():
	n = 1000000
	prime = [True for i in range(n + 1)]
	p = 2
	while p * p <= n:
		if prime[p] == True:
			for i in range(p * 2, n + 1, p):
				prime[i] = False
		p += 1
	prime[0] = False
	prime[1] = False
	s = []
	s.append(0)
	for p in range(1, n + 1):
		if prime[p]:
			s.append(s[p - 1] + p)
		else:
			s.append(s[p - 1])
	t = int(input())
	for _ in range(t):
		num = int(input())
		print(s[num] % 10)
main()


import math
N = 1000003
dp = [0] * (N + 1)

def seive():
	array = [0] * (N + 1)
	array[0] = 1
	array[1] = 1
	for i in range(2, math.ceil(math.sqrt(N) + 1)):
		if array[i] == 0:
			for j in range(i * i, N + 1, i):
				array[j] = 1
	runningPrimeSum = 0
	for i in range(1, N + 1):
		if array[i] == 0:
			runningPrimeSum += i
		dp[i] = runningPrimeSum
seive()
t = int(input())
for _ in range(t):
	n = int(input())
	print(dp[n] % 10)


def SieveOfEratosthenes(n):
	prime = [True for i in range(n + 1)]
	p = 2
	while p * p <= n:
		if prime[p] == True:
			for i in range(p * p, n + 1, p):
				prime[i] = False
		p += 1
	c = 0
	for p in range(2, n + 1):
		if prime[p]:
			c += p
	return c % 10
for i in range(int(input())):
	c = SieveOfEratosthenes(int(input()))
	print(c)


import math

def sieve(x):
	l = [0] * x
	h = int(math.sqrt(x))
	for i in range(2, h + 1):
		if l[i - 1] == 0:
			for j in range(i * i, x + 1, i):
				l[j - 1] = 1
	l1 = []
	for k in range(2, x + 1):
		if l[k - 1] == 0:
			l1.append(k)
	print(sum(l1) % 10)

def __starting_point():
	t = int(input())
	for i in range(t):
		n = int(input())
		sieve(n)
__starting_point()


def prime(n):
	l1 = [True] * (n + 1)
	i = 2
	while i * i <= n:
		if l1[i] == True:
			a = i * 2
			while a <= n:
				l1[a] = False
				a = a + i
		i = i + 1
	s1 = 0
	for i in range(2, n + 1):
		if l1[i]:
			s1 = s1 + i
	return s1
for _ in range(int(input())):
	n = int(input())
	s1 = prime(n)
	print(s1 % 10)


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

def __starting_point():
	for _ in range(int(input())):
		n = int(input())
		print(sumofprimes(n) % 10)
__starting_point()


n = 1000001
sieve = [0] * (n + 1)
sieve[0] = 1
sieve[1] = 1
for x in range(2, n + 1):
	if sieve[x]:
		continue
	for u in range(2 * x, n + 1, x):
		sieve[u] = 1
for i in range(int(input())):
	n = int(input())
	count = 0
	sum1 = 0
	for i in range(n + 1):
		if sieve[i] == 0:
			sum1 += i
	print(sum1 % 10)


def SieveOfEratosthenes(n):
	prime = [True for i in range(n + 1)]
	p = 2
	while p * p <= n:
		if prime[p] == True:
			for i in range(p * p, n + 1, p):
				prime[i] = False
		p += 1
	sum = 0
	for p in range(2, n + 1):
		if prime[p]:
			sum += p
	return sum
x = int(input())
for i in range(0, x):
	uptil = int(input())
	sum = SieveOfEratosthenes(uptil)
	print(sum % 10)


try:

	def findprimes(n, l):
		prime = [True for i in range(n + 1)]
		p = 2
		while p * p <= n:
			if prime[p] == True:
				for i in range(p * p, n + 1, p):
					prime[i] = False
			p += 1
		for i in range(2, n + 1):
			if prime[i] == True:
				l.append(i)
		return l
	for _ in range(int(input())):
		n = int(input())
		l = []
		findprimes(n, l)
		s = sum(l)
		print(s % 10)
except:
	pass


for t in range(int(input())):
	n = int(input())
	A = [True for i in range(n + 1)]
	(A[0], A[1]) = (False, False)
	i = 2
	while i ** 2 <= n:
		if A[i] == True:
			for j in range(i ** 2, n + 1, i):
				A[j] = False
		i += 1
	sum = 0
	for i in range(2, n + 1):
		if A[i] == True:
			sum += i
			if sum >= 10:
				sum %= 10
	print(sum)