Ms. E.T. came from planet Hex. She has 8 fingers in each hand which makes her count in hexadecimal way. When she meets you, she tells you that she came from 7E light years from the planet Earth. You see she means that it is 126 light years far away and she is telling you the numbers in hexadecimal. Now, you are in trouble to understand what those numbers really mean. Therefore, you have to convert the hexadecimal numbers to decimals.

Input:

First line of code contain T test cases.

every line of text case contain a Hex-value 

Output:

Every line of output contain a decimal conversion of given nunmber

Sample Input:

3

A

1A23

2C2A

Sample Output:

10

6691

11306

Difficulty: UNKNOWN_DIFFICULTY

Starter code:

Solutions:
try:
	t = int(input())
	for i in range(t):
		s = input()
		i = int(s, 16)
		print(i)
except EOFError as e:
	print(e)


try:
	n = int(input())
	for i in range(n):
		a = input()
		print(int(a, 16))
except EOFError as e:
	pass


t = int(input())
for i in range(t):
	s = input()
	print(int(s, 16))


t = int(input())
for i in range(t):
	str1 = input()
	str1 = str1[::-1]
	ans = 0
	for j in range(len(str1)):
		if str1[j] == '0' or str1[j] == '1' or str1[j] == '2' or (str1[j] == '3') or (str1[j] == '4') or (str1[j] == '5') or (str1[j] == '6') or (str1[j] == '7') or (str1[j] == '8') or (str1[j] == '9'):
			ans += int(str1[j]) * 16 ** j
		elif str1[j] == 'A':
			ans += 10 * 16 ** j
		elif str1[j] == 'B':
			ans += 11 * 16 ** j
		elif str1[j] == 'C':
			ans += 12 * 16 ** j
		elif str1[j] == 'D':
			ans += 13 * 16 ** j
		elif str1[j] == 'E':
			ans += 14 * 16 ** j
		elif str1[j] == 'F':
			ans += 15 * 16 ** j
	print(ans)


try:
	t = int(input())
	for _ in range(t):
		f = str(input())
		res = int(f, 16)
		print(str(res))
except:
	pass


t = int(input())
for _ in range(t):
	n = input()
	print(int(n, 16))


t = int(input())
for _ in range(t):
	s = input()
	l = len(s)
	(d, j) = (0, 0)
	for i in range(l - 1, -1, -1):
		if s[i] == 'A':
			d += 10 * 16 ** j
		elif s[i] == 'B':
			d += 11 * 16 ** j
		elif s[i] == 'C':
			d += 12 * 16 ** j
		elif s[i] == 'D':
			d += 13 * 16 ** j
		elif s[i] == 'E':
			d += 14 * 16 ** j
		elif s[i] == 'F':
			d += 15 * 16 ** j
		else:
			d += int(s[i]) * 16 ** j
		j += 1
	print(d)


test_case = int(input())
for _ in range(test_case):
	str = input()
	i = int(str, 16)
	print(i)


T = int(input())
for _ in range(T):
	a = str(input())
	x = int(a, 16)
	print(x)


T = int(input())
for _ in range(T):
	value = input()
	print(int(value, 16))


for _ in range(int(input())):
	print(int(input(), 16))


t = int(input())
for _ in range(t):
	test_string = input()
	res = int(test_string, 16)
	print(str(res))


t = int(input())
while t:
	t = t - 1
	hex = list(input())
	dec = 0
	l = len(hex) - 1
	for i in range(len(hex)):
		if hex[i] not in 'ABCDEF':
			dec = dec + 16 ** (l - i) * int(hex[i])
		elif hex[i] == 'A':
			dec = dec + 16 ** (l - i) * 10
		elif hex[i] == 'B':
			dec = dec + 16 ** (l - i) * 11
		elif hex[i] == 'C':
			dec = dec + 16 ** (l - i) * 12
		elif hex[i] == 'D':
			dec = dec + 16 ** (l - i) * 13
		elif hex[i] == 'E':
			dec = dec + 16 ** (l - i) * 14
		else:
			dec = dec + 16 ** (l - i) * 15
	print(dec)


t = int(input())
for i in range(t):
	h = list(reversed(list(input())))
	v = 'ABCDEF'
	r = [10, 11, 12, 13, 14, 15]
	x = 0
	for j in range(len(h)):
		if h[j] not in v:
			x = x + int(h[j]) * 16 ** j
		else:
			y = r[v.index(h[j])]
			x = x + int(y) * 16 ** j
	print(x)


for i in range(int(input())):
	x = input()
	hex = int(x, 16)
	print(str(hex))


for t in range(int(input())):
	print(int(input(), 16))


for i in range(int(input())):
	a = input()
	b = int(a, 16)
	print(b)


h = {'1': 1, '2': 2, '3': 3, '4': 4, '5': 5, '6': 6, '7': 7, '8': 8, '9': 9, 'A': 10, 'B': 11, 'C': 12, 'D': 13, 'E': 14, 'F': 15}
res = []
T = int(input())
for i in range(T):
	s = input()
	l = len(s)
	count = 0
	for j in range(l):
		count += h[s[j]] * 16 ** (l - j - 1)
	res.append(count)
for num in res:
	print(num)


try:
	t = int(input())
	while t > 0:
		hexdec = input()
		if hexdec == 'x':
			return
		else:
			dec = int(hexdec, 16)
			print(str(dec))
	t -= 1
except EOFError:
	pass