There is a building consisting of $10~000$ apartments numbered from $1$ to $10~000$, inclusive.

Call an apartment boring, if its number consists of the same digit. Examples of boring apartments are $11, 2, 777, 9999$ and so on.

Our character is a troublemaker, and he calls the intercoms of all boring apartments, till someone answers the call, in the following order:

  First he calls all apartments consisting of digit $1$, in increasing order ($1, 11, 111, 1111$).  Next he calls all apartments consisting of digit $2$, in increasing order ($2, 22, 222, 2222$)  And so on. 

The resident of the boring apartment $x$ answers the call, and our character stops calling anyone further.

Our character wants to know how many digits he pressed in total and your task is to help him to count the total number of keypresses.

For example, if the resident of boring apartment $22$ answered, then our character called apartments with numbers $1, 11, 111, 1111, 2, 22$ and the total number of digits he pressed is $1 + 2 + 3 + 4 + 1 + 2 = 13$.

You have to answer $t$ independent test cases.


-----Input-----

The first line of the input contains one integer $t$ ($1 \le t \le 36$) — the number of test cases.

The only line of the test case contains one integer $x$ ($1 \le x \le 9999$) — the apartment number of the resident who answered the call. It is guaranteed that $x$ consists of the same digit.


-----Output-----

For each test case, print the answer: how many digits our character pressed in total.


-----Example-----
Input
4
22
9999
1
777

Output
13
90
1
66

Source: codeforces | Difficulty: EASY
Tags: Mathematics

Implementation


Solutions:
for _ in range(int(input())):
	n = input()
	l = len(n)
	number = int(n) % 10
	ans = 0
	for i in range(1, number):
		ans += 10
	total = 0
	for i in range(1, l + 1):
		total += i
	ans += total
	print(ans)


n = int(input())
for i in range(n):
	number = input()
	b = 0
	for j in range(len(number)):
		b += j + 1
	ans = (int(number[0]) - 1) * 10 + b
	print(ans)


t = int(input())
sum = [1, 3, 6, 10]
for i in range(1, t + 1):
	x = input()
	i = int(len(x))
	x = int(x)
	result = (x % 10 - 1) * 10 + sum[i - 1]
	print(result)


for _ in range(int(input())):
	num_lst = list(input())
	num = int(num_lst[0]) - 1
	leng_list = len(num_lst)
	total_press = num * 10 + leng_list * (leng_list + 1) // 2
	print(total_press)


t = int(input())
for i in range(t):
	n = input()
	fd = int(n[0])
	s = 0
	s += (fd - 1) * 10
	l = len(n)
	s += l * (l + 1) // 2
	print(s)


for t in range(int(input())):
	n = int(input())
	dig = 1
	count = 0
	apa = 0
	fou = 0
	pre = 0
	for dig in range(1, 10):
		apa = 0
		pre = 0
		while apa * 10 + dig < 10000.0:
			if n == apa:
				fou = count
			apa = apa * 10 + dig
			pre += 1
			count += pre
		if n == apa:
			fou = count
	ans2 = fou
	print(fou)


t = int(input())
lis = [1, 11, 111, 1111, 2, 22, 222, 2222, 3, 33, 333, 3333, 4, 44, 444, 4444, 5, 55, 555, 5555, 6, 66, 666, 6666, 7, 77, 777, 7777, 8, 88, 888, 8888, 9, 99, 999, 9999]
for _ in range(t):
	ser = int(input())
	ind = lis.index(ser) + 1
	first = ind // 4
	second = ind % 4
	ans = first * 10 + second * (second + 1) // 2
	print(ans)


import math
z = [1, 11, 111, 1111, 2, 22, 222, 2222, 3, 33, 333, 3333, 4, 44, 444, 4444, 5, 55, 555, 5555, 6, 66, 666, 6666, 7, 77, 777, 7777, 8, 88, 888, 8888, 9, 99, 999, 9999]
t = int(input())
for _ in range(t):
	n = int(input())
	i = 0
	if n == 9999:
		print(90)
	else:
		for i in range(36):
			if z[i] == n:
				break
		ans = 0
		for k in range(i + 1):
			ans += math.floor(math.log(z[k], 10) + 1)
		print(ans)


t = int(input())
ansLst = []
for tt in range(t):
	x = input()
	first = int(x[0])
	ans = (first - 1) * 10 + len(x) * (len(x) + 1) // 2
	ansLst.append(ans)
for i in ansLst:
	print(i)


t = int(input())
for _ in range(t):
	x = input()
	ans = 0
	flag = False
	for i in range(1, 10):
		s = str(i)
		while s != x and len(s) < 5:
			ans = ans + len(s)
			s = s + str(i)
		if s == x:
			ans = ans + len(s)
			flag = True
		if flag:
			break
	print(ans)


a = [0, 1, 3, 6, 10]
for tc in range(int(input())):
	n = input()
	ans = a[len(n)]
	print(ans + (int(n[0]) - 1) * 10)


for _ in range(int(input())):
	n = [1, 11, 111, 1111]
	a = []
	b = []
	count = 0
	for y in range(1, 10):
		for x in n:
			a.append(x * y)
	x = int(input())
	i = a.index(x)
	c = a[:i + 1]
	for t in c:
		b.append(str(t))
		count += len(str(t))
	print(count)


t = int(input())
for _ in range(t):
	N = list(input())
	c = len(N)
	n = int(N[0])
	print(int((c + 1) * c / 2) + 10 * (n - 1))


for _ in range(int(input())):
	s = input().strip()
	d = int(s[0])
	n = len(s)
	print(10 * (d - 1) + (n + 1) * n // 2)


T = int(input())
for i in range(T):
	N = int(input())
	s = str(N)
	x = len(s)
	r = int(s[0])
	ans = 0
	final = [1, 2, 3, 4]
	if r - 1 > 0:
		final = final * (r - 1)
	for k in range(x):
		if r > 1:
			final[k] = final[k] + (k + 1)
	if r == 1 and x == 1:
		ans = 1
	elif r == 1 and x != 1:
		ans = sum(final[:x])
	else:
		ans = sum(final)
	print(ans)


def boring_seq(maxx=10000):
	seq = []
	for digit in range(1, 10):
		apt_no = digit
		seq.append(apt_no)
		next_apt_no = apt_no * 10 + digit
		while next_apt_no <= maxx:
			seq.append(next_apt_no)
			next_apt_no = next_apt_no * 10 + digit
	return seq

def n_keys(answered):
	prev_numbers_keys = 10 * (answered % 10 - 1)
	this_numbers_keys = sum(range(1, len(str(answered)) + 1))
	n_keys = prev_numbers_keys + this_numbers_keys
	return n_keys
n_cases = int(input())
for i in range(n_cases):
	answered = int(input())
	print(n_keys(answered))


t = int(input())
for _ in range(t):
	n = int(input())
	s = str(n)
	l = len(s)
	rem = 0
	sum = 0
	rem = n % 10
	sum = (rem - 1) * 10 + l * (l + 1) / 2
	print(int(sum))


t = int(input())
for i in range(t):
	(n, k) = (input(), 0)
	s = int(n[0])
	k += 10 * (s - 1) + len(n) * (len(n) + 1) // 2
	print(k)


t = int(input())
for _ in range(t):
	n = int(input())
	p = int(str(n)[0])
	k = len(str(n))
	tot = (p - 1) * 10 + k * (k + 1) // 2
	print(tot)


t = int(input())
for h in range(t):
	h = list(input())
	x = int(h[0])
	ans = 0
	ans += 10 * (x - 1)
	for i in range(len(h) + 1):
		ans += i
	print(ans)


for _ in ' ' * int(input()):
	a = int(input())
	k = int(str(a)[0])
	o = k - 1
	p = len(str(a))
	ans = 10 * o + p * (p + 1) // 2
	print(ans)


t = int(input())
for _ in range(t):
	x = input()
	ans = (int(x[0]) - 1) * 10
	n = len(x)
	ans += n * (n + 1) // 2
	print(ans)


for i in range(int(input())):
	n = input()
	l = []
	s = ''
	for i in range(1, 10):
		s = ''
		for j in range(1, 5):
			s += str(i)
			l.append(s)
	sumv = 0
	for i in range(len(l)):
		if n == l[i]:
			sumv += len(l[i])
			break
		else:
			sumv += len(l[i])
	print(sumv)


for i in range(int(input())):
	x = int(input())
	s = (int(str(x)[0]) - 1) * 10
	for i in range(1, len(str(x)) + 1):
		s += i
	print(s)


for _ in range(int(input())):
	x = input()
	num = int(x[0])
	num = (num - 1) * 10
	if len(x) == 1:
		print(num + 1)
	elif len(x) == 2:
		print(num + 3)
	elif len(x) == 3:
		print(num + 6)
	else:
		print(num + 10)


t = int(input())
while t > 0:
	n = input()
	l = len(n)
	s = 4 * (1 + 4) // 2 * (int(n[0]) - 1)
	s += l * (1 + l) // 2
	print(s)
	t = t - 1


for _ in range(int(input())):
	n = int(input())
	a = n % 10
	s = 10 * (a - 1)
	if n > 1000:
		print(s + 10)
	elif n > 100:
		print(s + 6)
	elif n > 10:
		print(s + 3)
	else:
		print(s + 1)


a = int(input())
for x in range(a):
	f = 0
	b = input()
	d = len(b)
	if d == 1:
		f += 1
	elif d == 2:
		f += 3
	elif d == 3:
		f += 6
	elif d == 4:
		f += 10
	j = b[0]
	k = 10 * (int(j) - 1)
	f += k
	print(f)


t = int(input())
for k in range(t):
	n = input()
	apart = int(n[0])
	ans = apart * 10
	if len(n) == 4:
		print(ans)
	else:
		s = 0
		for j in range(len(n) + 1, 5):
			s += j
		ans = ans - s
		print(ans)


h = int(input())
while h:
	n = input()
	l = len(str(n))
	no = int(n[0]) - 1
	print(no * 10 + l * (l + 1) // 2)
	h -= 1


for i in range(int(input())):
	x = int(input())
	m = str(x)
	n = m[0]
	o = len(m)
	print((int(n) - 1) * 10 + o * (o + 1) // 2)


for _ in range(int(input())):
	n = input()
	s = len(n)
	t = int(n) % 10
	k = (t - 1) * 10 + s * (s + 1) // 2
	print(k)


t = int(input())
for _ in range(t):
	n = input()
	x = int(n[0])
	ans = (x - 1) * 10
	if len(n) == 1:
		ans += 1
	elif len(n) == 2:
		ans += 3
	elif len(n) == 3:
		ans += 6
	elif len(n) == 4:
		ans += 10
	print(ans)


t = int(input())
for _ in range(t):
	n = int(input())
	d = n % 10
	c = 0
	while n > 0:
		n //= 10
		c += 1
	print(int((d - 1) * 10 + c * (c + 1) // 2))


a = int(input())
b = [1, 11, 111, 1111, 2, 22, 222, 2222, 3, 33, 333, 3333, 4, 44, 444, 4444, 5, 55, 555, 5555, 6, 66, 666, 6666, 7, 77, 777, 7777, 8, 88, 888, 8888, 9, 99, 999, 9999]
c = [1, 3, 6, 10, 11, 13, 16, 20, 21, 23, 26, 30, 31, 33, 36, 40, 41, 43, 46, 50, 51, 53, 56, 60, 61, 63, 66, 70, 71, 73, 76, 80, 81, 83, 86, 90, 91, 93, 96, 100]
for i in range(a):
	x = int(input())
	for j in range(len(b)):
		if b[j] == x:
			print(c[j])


def cnt_clicks(n):
	cnt = 0
	a = n % 10
	while n != 0:
		n //= 10
		cnt += 1
	ans = 10 * (a - 1) + cnt * (cnt + 1) // 2
	return ans
t = int(input())
for i in range(t):
	n = int(input())
	print(cnt_clicks(n))


vector = []
for k in range(1, 10):
	for i in range(1, 5):
		vector.append(str(k) * i)
t = int(input())
for i in range(t):
	n = int(input())
	suma = 0
	for k in range(len(vector)):
		suma += len(vector[k])
		if int(vector[k]) == n:
			break
	print(suma)


def solve(n):
	u = n % 10
	sum = (u - 1) * 10
	s = len(str(n))
	while s > 0:
		sum += s
		s -= 1
	return sum
T = int(input())
for t in range(T):
	n = int(input())
	print(solve(n))


for i in range(int(input())):
	a = input()
	c = len(a)
	d = int(a[0])
	f = 0
	for i in range(1, c + 1):
		f += i
	x = 10 * (d - 1) + f
	print(x)


import math
t = int(input())
for _ in range(t):
	s = input()
	n = int(s)
	d = int(s[0])
	c = (d - 1) * 10
	l = 1
	i = d
	cc = 1
	while i < n:
		c += cc
		i = i * 10 + d
		l += 1
		cc += 1
	c += cc
	print(c)


t = int(input())
queue = []
for i in range(1, 10):
	queue.extend([f'{i}' * n for n in range(1, 5)])
cumsum = []
cur = 0
for i in range(len(queue)):
	cur += len(queue[i])
	cumsum.append(cur)
ans = []
for _ in range(t):
	example = input()
	ans.append(cumsum[queue.index(example)])
for a in ans:
	print(a)


for __ in range(int(input())):
	a = int(input())
	b = [1, 2, 3, 4]
	a = str(a)
	d = (int(a[0]) - 1) * 10 + sum(b[:len(a)])
	print(d)


def solve(num):
	if len(num) == 1:
		print((int(num[0]) - 1) * 10 + 1)
	elif len(num) == 2:
		print((int(num[0]) - 1) * 10 + 3)
	elif len(num) == 2:
		print((int(num[0]) - 1) * 10 + 3)
	elif len(num) == 3:
		print((int(num[0]) - 1) * 10 + 6)
	else:
		print((int(num[0]) - 1) * 10 + 10)
i = int(input())
for a in range(i):
	solve(input())


for _ in range(int(input())):
	x = int(input())
	a = len(str(x))
	b = 1
	while a > 1:
		b += a
		a -= 1
	print(10 * (x % 10 - 1) + b)


a = int(input())
l1 = []
for i in range(a):
	b = int(input())
	(z, i, j) = (0, 0, 0)
	l = [1, 2, 3, 4]
	c = b
	while c != 0:
		c //= 10
		z = z + l[i]
		i = i + 1
	l1.append(z + 10 * (b % 10 - 1))
for i in l1:
	print(i)


t = [1, 3, 6, 10]
for i in range(int(input())):
	k = input()
	print(10 * (int(k[0]) - 1) + t[len(k) - 1])


def solve(x):
	result = 0
	for digit in range(1, 10):
		for length in range(1, 5):
			result += length
			if str(digit) * length == str(x):
				return result
for _ in range(int(input())):
	x = int(input())
	print(solve(x))


def solve(x):
	v = [1, 11, 111, 1111, 2, 22, 222, 2222, 3, 33, 333, 3333, 4, 44, 444, 4444, 5, 55, 555, 5555, 6, 66, 666, 6666, 7, 77, 777, 7777, 8, 88, 888, 8888, 9, 99, 999, 9999]
	sm = 0
	i = 0
	while x != v[i]:
		sm += len(str(v[i]))
		i += 1
	sm += len(str(v[i]))
	return sm

def main():
	t = int(input())
	for q_itr in range(t):
		x = int(input())
		print(solve(x))
main()


import os
import sys
from io import BytesIO, IOBase
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
input = lambda : sys.stdin.readline().rstrip('\r\n')
for j in range(int(input())):
	x = int(input())
	length = len(str(x))
	dig = int(str(x)[0])
	ans = (dig - 1) * (2 * 5)
	ans += length * (length + 1) // 2
	print(ans)


for _ in range(int(input())):
	n = int(input())
	(s, si, c) = ('1', 1, 0)
	x = 0
	while int(s) != n:
		c += len(s)
		s += str(si)
		if len(s) > 4:
			si += 1
			s = str(si)
	print(c + len(s))


for u in range(int(input())):
	n = int(input())
	d = str(n)
	r = int(d[0])
	c = 0
	for i in range(1, 10000):
		s = str(i)
		x = int(s[0])
		if x < r:
			if len(set(s)) == 1:
				c += len(s)
		if x == r and i <= n:
			if len(set(s)) == 1:
				c += len(s)
	print(c)


t = int(input())
for i in range(0, t):
	x = input()
	d = (int(x[0]) - 1) * 10
	if len(x) == 4:
		d = d + 10
	elif len(x) == 3:
		d = d + 6
	elif len(x) == 2:
		d = d + 3
	else:
		d = d + 1
	print(d)


for i in range(int(input())):
	x = input()
	ans = 0
	ans = ans + (int(x[0]) - 1) * 10
	ans = ans + [1, 3, 6, 10][len(x) - 1]
	print(ans)


def apt(x):
	dig = 0
	Count = 0
	while x > 0:
		dig = x % 10
		x = x // 10
		Count += 1
	return (dig - 1) * 10 + Count * (Count + 1) // 2
t = int(input())
for i in range(t):
	x = int(input())
	print(apt(x))


t = int(input())
for i in range(t):
	x = int(input())
	strX = str(x)
	n = int(len(strX))
	firstNumber = int(strX[0])
	counter = 0
	if firstNumber <= 9:
		for j in range(1, firstNumber + 1, 1):
			if j != firstNumber:
				counter += 10
			elif n == 1:
				counter += 1
			elif n == 2:
				counter += 3
			elif n == 3:
				counter += 6
			elif n == 4:
				counter += 10
		print(counter)
	elif firstNumber == 1:
		if n == 4:
			print(10)
		elif n == 3:
			print(6)
		elif n == 2:
			print(3)
		elif n == 1:
			print(1)


t = int(input())
for i in range(t):
	n = input()
	length = len(n)
	first = int(n[0])
	print((first - 1) * 10 + length * (length + 1) // 2)


t = int(input())
for _ in range(t):
	a = input()
	n = int(a[0])
	x = len(a)
	res = (n - 1) * 10 + x * (x + 1) // 2
	print(res)


import sys, collections, math, itertools, random
INF = sys.maxsize

def get_ints():
	return map(int, sys.stdin.readline().strip().split())

def get_array():
	return list(map(int, sys.stdin.readline().strip().split()))

def input():
	return sys.stdin.readline().strip()
mod = 1000000007
for _ in range(int(input())):
	s = input()
	n = int(s[0])
	arr = [1, 2, 3, 4]
	l = len(s)
	mx = 4 * (4 + 1) // 2
	print(mx * n - sum(arr[l:]))


for test in range(int(input())):
	room = input()
	x = int(room[0]) - 1
	print(x * 10 + len(room) * (1 + len(room)) // 2)


for _ in range(int(input())):
	x = input()
	a = int(x[0])
	ans = (a - 1) * 10
	a = len(x)
	a = a * (a + 1) // 2
	ans += a
	print(ans)


t = int(input())
for z in range(t):
	x = int(input())
	r = x % 10
	c = 0
	for j in range(len(str(x)) + 1):
		c += j
	print(10 * (r - 1) + c)


import sys
import math as m

def main():
	pass

def binary(n):
	return bin(n).replace('0b', '')

def decimal(s):
	return int(s, 2)

def pow2(n):
	p = 0
	while n > 1:
		n //= 2
		p += 1
	return p

def isPrime(n):
	if n == 1:
		return False
	else:
		root = int(n ** 0.5)
		root += 1
		for i in range(2, root):
			if n % i == 0:
				return False
		return True

def lts(l):
	s = ''.join(map(str, l))
	return s

def stl(s):
	l = list(s)
	return l

def sq(a, target, arr=[]):
	s = sum(arr)
	if s == target:
		return arr
	if s >= target:
		return
	for i in range(len(a)):
		n = a[i]
		remaining = a[i + 1:]
		ans = sq(remaining, target, arr + [n])
		if ans:
			return ans
mod = int(1000000000.0) + 7

def sinp():
	return sys.stdin.readline().strip()

def iinp():
	return int(input())

def ninp():
	return map(int, sys.stdin.readline().strip().split())

def llinp():
	return list(map(int, sys.stdin.readline().strip().split()))

def p(xyz):
	print(xyz)

def p2(a, b):
	print(a, b)
for _ in range(iinp()):
	x = sinp()
	dig = x[0]
	ans = (int(dig) - 1) * 10
	tot = 0
	for c in x:
		tot = tot + 1
	if tot == 1:
		print(ans + 1)
	elif tot == 2:
		print(ans + 3)
	elif tot == 3:
		print(ans + 6)
	elif tot == 4:
		print(ans + 10)


t = int(input())
for i in range(t):
	n = input()
	d = ord(n[0]) - ord('0')
	p = (d - 1) * 10 + len(n) * (len(n) + 1) // 2
	print(p)


for i in range(int(input())):
	x = int(input())
	a = [1, 11, 111, 1111, 2, 22, 222, 2222, 3, 33, 333, 3333, 4, 44, 444, 4444, 5, 55, 555, 5555, 6, 66, 666, 6666, 7, 77, 777, 7777, 8, 88, 888, 8888, 9, 99, 999, 9999]
	ind = a.index(x)
	s = 0
	for i in range(ind + 1):
		s += len(str(a[i]))
	print(s)


import math
import sys
import collections
import bisect
input = sys.stdin.readline
flush = sys.stdout.flush
readint = lambda : int(input())
readintm = lambda : map(int, input().strip().split())
readintl = lambda : list(map(int, input().strip().split()))
readfloatm = lambda : map(float, input().strip().split())
readfloatl = lambda : list(map(float, input().strip().split()))
readstr = lambda : input().strip()
readstrl = lambda : list(input().strip())
join = lambda x, l: x.join(map(str, l))
print = lambda *x: sys.stdout.write(' '.join(map(str, x)) + '\n')
printl = lambda l: sys.stdout.write(' '.join(map(str, l)) + '\n')
ceil = lambda x, y: (x + y - 1) // y
mod = 1000000007
for _ in range(readint()):
	x = readint()
	print(10 * (x % 10 - 1) + len(str(x)) * (len(str(x)) + 1) // 2)


n = int(input())
a = [1, 11, 111, 1111, 2, 22, 222, 2222, 3, 33, 333, 3333, 4, 44, 444, 4444, 5, 55, 555, 5555, 6, 66, 666, 6666, 7, 77, 777, 7777, 8, 88, 888, 8888, 9, 99, 999, 9999]
for i in range(n):
	num = int(input())
	k = a.index(num) + 1
	if k % 4 == 0:
		print(10 * (k // 4))
	elif k % 4 == 1:
		print(10 * (k // 4) + 1)
	elif k % 4 == 2:
		print(10 * (k // 4) + 3)
	else:
		print(10 * (k // 4) + 6)


T = int(input())

def Compute():
	x = input()
	lenx = len(x)
	xfirst = int(x[0])
	N = (xfirst - 1) * 10
	return N + lenx * (lenx + 1) / 2
for t in range(1, T + 1):
	print(int(Compute()))


t = int(input())
for r in range(t):
	n = int(input())
	s = len(str(n))
	p = str(n)[0]
	c = 10 * (int(p) - 1)
	for i in range(s + 1):
		c += i
	print(c)


t = int(input())
while t:
	t -= 1
	s = input()
	ans = 0
	for i in range(int(s[0]) - 1):
		ans += 10
	j = 1
	for i in range(len(s)):
		ans += j
		j += 1
	print(ans)


def nsum(kv):
	k = 0
	tk = kv
	while tk != '':
		k += len(tk)
		tk = '' + tk[:len(tk) - 1]
	return k
t = int(input())
nz = list()
for i in range(0, t):
	kv = str(input())
	tn = (int(kv[0]) - 1) * 10 + nsum(kv)
	nz.append(tn)
for i in range(0, t):
	print(nz[i])


for i in range(int(input())):
	a = input()
	b = len(a)
	print(10 * (int(a[0]) - 1) + b * (b + 1) // 2)


x = int(input())
flats = [1, 11, 111, 1111, 2, 22, 222, 2222, 3, 33, 333, 3333, 4, 44, 444, 4444, 5, 55, 555, 5555, 6, 66, 666, 6666, 7, 77, 777, 7777, 8, 88, 888, 8888, 9, 99, 999, 9999]
ans = []
for i in range(0, x):
	summ = 0
	for i in range(0, flats.index(int(input())) + 1):
		if flats[i] // 10 < 1:
			summ += 1
		elif flats[i] // 10 < 10:
			summ += 2
		elif flats[i] // 10 < 100:
			summ += 3
		elif flats[i] // 10 < 1000:
			summ += 4
	ans.append(summ)
for i in ans:
	print(i)


t = int(input())
for j in range(t):
	n = input()
	l = len(n)
	ans = (int(n[0]) - 1) * 10
	for i in range(1, l + 1):
		ans += i
	print(ans)


def recursion(a):
	summ = 0
	for j in range(0, a + 1):
		summ += j
	return summ
n = int(input())
for i in range(n):
	i = input()
	print(recursion(4) * (int(i) % 10 - 1) + recursion(len(i)))


n = int(input())
for i in range(n):
	k = int(input())
	a = 0
	if len(str(k)) == 4:
		a = 10
	elif len(str(k)) == 3:
		a = 6
	elif len(str(k)) == 2:
		a = 3
	else:
		a = 1
	kstr = str(k)
	print((int(kstr[0]) - 1) * 10 + a)


for _ in range(int(input())):
	n = int(input())
	l = n % 10
	a = len(str(n))
	res = a * (a + 1) / 2
	res += (l - 1) * 10
	print(int(res))


t = int(input())
l1 = [[1, 11, 111, 1111], [2, 22, 222, 2222], [3, 33, 333, 3333], [4, 44, 444, 4444], [5, 55, 555, 5555], [6, 66, 666, 6666], [7, 77, 777, 7777], [8, 88, 888, 8888], [9, 99, 999, 9999]]
for _ in range(t):
	n = input()
	ans = 0
	x = int(n[0])
	y = l1[x - 1]
	ans += 10 * (x - 1)
	a = y.index(int(n))
	b = 1
	for i in range(a + 1):
		ans += b
		b += 1
	print(ans)


import os
from sys import stdin, stdout

def solve(tc):
	x = int(stdin.readline().strip())
	cnt = 0
	for i in range(1, 10):
		base = 0
		for j in range(4):
			base *= 10
			base += i
			cnt += j + 1
			if x == base:
				print(cnt)
				return
tcs = 1
tcs = int(stdin.readline().strip())
tc = 1
while tc <= tcs:
	solve(tc)
	tc += 1


t = int(input())
while t > 0:
	t -= 1
	x = int(input())
	a = []
	while x > 0:
		a.append(x % 10)
		x = x // 10
	ans = 0
	if a[0] == 1:
		k = len(a)
		while k > 0:
			ans += k
			k -= 1
	else:
		k = len(a)
		while k > 0:
			ans += k
			k -= 1
		ans += 10 * (a[0] - 1)
	print(ans)


from sys import stdin, stdout
import math
from itertools import permutations, combinations
from collections import defaultdict
from collections import Counter
from bisect import bisect_left
import sys
from queue import PriorityQueue
import operator as op
from functools import reduce
mod = 1000000007

def L():
	return list(map(int, stdin.readline().split()))

def In():
	return map(int, stdin.readline().split())

def I():
	return int(stdin.readline())

def printIn(ob):
	return stdout.write(str(ob) + '\n')

def powerLL(n, p):
	result = 1
	while p:
		if p & 1:
			result = result * n % mod
		p = int(p / 2)
		n = n * n % mod
	return result

def ncr(n, r):
	r = min(r, n - r)
	numer = reduce(op.mul, range(n, n - r, -1), 1)
	denom = reduce(op.mul, range(1, r + 1), 1)
	return numer // denom

def isPrime(n):
	for i in range(2, int(n ** 0.5) + 1):
		if n % i == 0:
			return False
	return True

def myCode():
	d = {1: 1, 2: 3, 3: 6, 4: 10}
	s = input()
	num = int(s)
	cnt = len(s)
	print((int(s[0]) - 1) * 10 + d[cnt])

def main():
	for t in range(I()):
		myCode()
main()


def digits(num):
	ct = 0
	l = []
	while num != 0:
		r = num % 10
		l.append(r)
		num = num // 10
		ct += 1
	return (ct, l)
t = int(input())
for i in range(t):
	n = int(input())
	(dig, li) = digits(n)
	su = 0
	for i in range(1, li[0] + 1):
		if i < li[0]:
			su = su + 10
		elif dig == 1:
			su = su + 1
		elif dig == 2:
			su = su + 3
		elif dig == 3:
			su = su + 6
		elif dig == 4:
			su = su + 10
	print(su)


for i in range(int(input())):
	n = int(input())
	if len(str(n)) == 4:
		print((int(str(n)[0]) - 1) * 10 + 10)
	if len(str(n)) == 3:
		print((int(str(n)[0]) - 1) * 10 + 6)
	if len(str(n)) == 2:
		print((int(str(n)[0]) - 1) * 10 + 3)
	if len(str(n)) == 1:
		print((int(str(n)[0]) - 1) * 10 + 1)


ITR = int(input())
for _ in range(ITR):
	N = input()
	re = 10 * (int(N[0]) - 1)
	for i in range(1, len(N) + 1, 1):
		re += i
	print(re)


ns = lambda : input()
ni = lambda : int(input())
nm = lambda : map(int, input().split())
nl = lambda : list(map(int, input().split()))
for _ in range(ni()):
	a = ni()
	s = 10 * (a % 10 - 1)
	l = len(str(a))
	s += l * (l + 1) // 2
	print(s)


def is_in(a, l):
	for i in l:
		if a == i:
			return True
	return False

def permutations():
	a = input()
	a = int(a)
	lis = []
	for i in range(a):
		b = input()
		sum = 0
		length = len(b)
		digit = int(b[0])
		sum += (digit - 1) * 10
		if length == 1:
			sum += 1
		elif length == 2:
			sum += 3
		elif length == 3:
			sum += 6
		else:
			sum += 10
		lis.append(str(sum))
	for i in lis:
		print(i)
permutations()


k = int(input())
e = [0, 0, 10, 20, 30, 40, 50, 60, 70, 80]
y = [0, 1, 3, 6, 10]
for i in range(k):
	q = int(input())
	q = str(q)
	r = e[int(q[0])] + y[q.count(q[0])]
	print(r)


for _ in range(int(input())):
	n = int(input())
	x = n % 10
	y = x - 1
	ans = 0
	ans = y * 10
	l = len(str(n))
	while n != 0:
		n //= 10
		ans += l
		l -= 1
	print(ans)


def cnt(test):
	flats = ''
	for number in range(1, 10):
		for q in range(1, 5):
			flat = str(number) * q
			flats += flat
			if flat == test:
				return str(len(flats))
i = int(input())
result = []
for test in range(i):
	test = input()
	result.append(cnt(test))
print('\n'.join(result))


def count(n):
	(ini, i, c) = (1, 1, 1)
	total = 0
	while i != n:
		total += c
		i = i * 10 + ini
		c += 1
		if i > 10000:
			ini = ini + 1
			i = ini
			c = 1
	return total + len(str(n))
t = int(input())
for i in range(t):
	print(count(int(input())))


for _ in range(int(input())):
	n = int(input())
	print((int(str(n)[0]) - 1) * 10 + len(str(n)) * (len(str(n)) + 1) // 2)


s = ''
for _ in range(int(input())):
	n = int(input())
	b = n % 10
	l = len(str(n))
	ans = (b - 1) * 10 + l * (l + 1) // 2
	print(ans)


from sys import stdout
from sys import stdin

def get():
	return stdin.readline().strip()

def getf():
	return [int(i) for i in get().split()]

def put(a, end='\n'):
	stdout.write(str(a) + end)

def putf(a, sep=' ', end='\n'):
	stdout.write(sep.join([str(i) for i in a]) + end)

def solve(n):
	d = dict()
	x = 0
	for i in range(1, 9 + 1):
		for k in range(1, 4 + 1):
			d[int(str(i) * k)] = x
			x += k
	return d[n] + len(str(n))

def main():
	q = int(get())
	for _ in range(q):
		put(solve(int(get())))
main()


from sys import stdin
input = stdin.readline
from bisect import bisect_left

def solve():
	n = int(input())
	s = str(n)
	l = len(s)
	print(10 * (int(s[0]) - 1) + l * (l + 1) // 2)
t = int(input())
for _ in range(t):
	solve()


t = int(input())
for ij in range(t):
	x = int(input())
	l = [1, 11, 111, 1111, 2, 22, 222, 2222, 3, 33, 333, 3333, 4, 44, 444, 4444, 5, 55, 555, 5555, 6, 66, 666, 6666, 7, 77, 777, 7777, 8, 88, 888, 8888, 9, 99, 999, 9999]
	count = 0
	for i in l:
		count += len(str(i))
		if i == x:
			break
	print(count)


boring = [1, 11, 111, 1111, 2, 22, 222, 2222, 3, 33, 333, 3333, 4, 44, 444, 4444, 5, 55, 555, 5555, 6, 66, 666, 6666, 7, 77, 777, 7777, 8, 88, 888, 8888, 9, 99, 999, 9999, 99999]
for _ in range(int(input())):
	n = int(input())
	i = 0
	count = 0
	while True:
		if boring[i] != n:
			count += len(str(boring[i]))
			i += 1
		elif boring[i] == n:
			count += len(str(boring[i]))
			break
	print(count)


for _ in range(int(input())):
	num = int(input())
	print((num % 10 - 1) * 10 + [1, 3, 6, 10][len(str(num)) - 1])


f = lambda : map(int, input().split())
for _ in range(int(input())):
	n = input()
	l = list()
	for i in range(1, 10):
		l.append(str(i) * 1)
		l.append(str(i) * 2)
		l.append(str(i) * 3)
		l.append(str(i) * 4)
	index = l.index(n)
	l = l[:index + 1]
	print(len(''.join(map(str, l))))


n = int(input())
a = []
b = [1, 11, 111, 1111, 2, 22, 222, 2222, 3, 33, 333, 3333, 4, 44, 444, 4444, 5, 55, 555, 5555, 6, 66, 666, 6666, 7, 77, 777, 7777, 8, 88, 888, 8888, 9, 99, 999, 9999]
while n > 0:
	a.append(int(input()))
	n = n - 1
for i in a:
	total = 0
	for k in range(b.index(i) + 1):
		total = total + len(str(b[k]))
	print(total)


a = int(input())
for q in range(a):
	b = input()
	s = 0
	print((int(b[0]) - 1) * 10 + len(b) * (len(b) + 1) // 2)


import sys
test_case_num = int(input())
for i in range(test_case_num):
	a = input()
	sum = 0
	for i in range(1, len(a) + 1):
		sum += i
	print((int(a) % 10 - 1) * 10 + sum)


for _ in range(int(input())):
	x = input()
	n = int(x[0])
	l = len(x)
	ans = 0
	for i in range(1, n):
		ans += 10
	for i in range(1, l + 1):
		ans += i
	print(ans)


from collections import defaultdict
for _ in range(int(input())):
	n = int(input())
	temp = [1, 11, 111, 1111]
	arr = list(temp)
	ans = [1, 3, 6, 10]
	for i in range(2, 10):
		p = 1
		for k in temp:
			arr.append(i * k)
			ans.append(ans[-1] + p)
			p += 1
	for i in range(36):
		if arr[i] == n:
			print(ans[i])


a = []
for i in range(1, 10):
	for j in range(1, 5):
		z = '1' * j
		a.append(int(z) * i)
t = int(input())
for _ in range(t):
	x = int(input())
	ans = -1
	for (i, el) in enumerate(a):
		if x == el:
			ans = i
			break
	fans = 0
	for i in range(ans + 1):
		fans += len(str(a[i]))
	print(fans)


for _ in range(int(input())):
	apar = input()
	presses = 10 * (int(apar[0]) - 1)
	for i in range(1, len(apar) + 1):
		presses += i
	print(presses)


for i in range(int(input())):
	k = input()
	print(10 * int(k[0]) - [0, 9, 7, 4, 0][len(k)])


X = list(map(int, input().split()))
t = X[0]
for i in range(t):
	X = list(map(int, input().split()))
	x = X[0]
	e = x
	i = 0
	while e // 10 != 0:
		e = e // 10
		i += 1
	i += 1
	print(10 * (e - 1) + i * (i + 1) // 2)


from sys import stdin, stdout
t = int(input())
for _ in range(t):
	x = input()
	val = int(x[0])
	ans = (val - 1) * 10
	if len(x) == 1:
		ans += 1
	elif len(x) == 2:
		ans += 3
	elif len(x) == 3:
		ans += 6
	else:
		ans += 10
	print(ans)


t = int(input())
while t > 0:
	t -= 1
	n = int(input())
	n = str(n)
	a = int(n[0])
	l = len(str(n))
	ans = 10 * (a - 1)
	if l == 1:
		ans += 1
	elif l == 2:
		ans += 3
	elif l == 3:
		ans += 6
	elif l == 4:
		ans += 10
	print(ans)


def solve():
	num = input()
	past_touch = (int(num[0]) - 1) * 10
	actual_touch = (1 + len(num)) * len(num) // 2
	print(past_touch + actual_touch)
tests = int(input())
while tests > 0:
	solve()
	tests -= 1


def getNum(x):
	list = [1, 3, 6, 10]
	return (int(x[0]) - 1) * 10 + list.pop(len(x) - 1)
t = int(input())
for i in range(t):
	num = input()
	print(getNum(num))


for _ in range(int(input())):
	n = input()
	p = n[0]
	count = 0
	count += (int(p) - 1) * 10
	if n >= p * len(n):
		count += len(n) * (len(n) + 1) // 2
	else:
		count += len(n) * (len(n) - 1) // 2
	print(count)


a = int(input())
for i in range(a):
	x = input()
	r = int(x[0])
	print((r - 1) * 10 + len(x) * (len(x) + 1) // 2)


test_cases = int(input())
lst = [1, 11, 111, 1111, 2, 22, 222, 2222, 3, 33, 333, 3333, 4, 44, 444, 4444, 5, 55, 555, 5555, 6, 66, 666, 6666, 7, 77, 777, 7777, 8, 88, 888, 8888, 9, 99, 999, 9999]
for i in range(test_cases):
	number = int(input())
	pos = lst.index(number) + 1
	cat = pos // 4
	rest = pos % 4
	if rest == 2:
		rest = 3
	elif rest == 3:
		rest = 6
	print(cat * 10 + rest)


from sys import stdin, stdout
input = stdin.readline
from collections import defaultdict as dd
import math

def geti():
	return list(map(int, input().strip().split()))

def getl():
	return list(map(int, input().strip().split()))

def gets():
	return input()

def geta():
	return int(input())

def print_s(s):
	stdout.write(s + '\n')

def solve():
	for _ in range(geta()):
		a = geta()
		ans = 0
		ans = 10 * (a % 10 - 1)
		while a:
			ans += len(str(a))
			a //= 10
		print(ans)

def __starting_point():
	solve()
__starting_point()


n = int(input())
l = [input() for st in range(n)]
for s in l:
	sum = 0
	for i in range(1, len(s) + 1):
		sum += i
	print(10 * (int(s[0]) - 1) + sum)


import sys
while True:
	line = sys.stdin.readline()
	if not line:
		break
	for cas in range(int(line)):
		n = int(input())
		m = n % 10
		ans = (m - 1) * 10
		(j, t) = map(int, [1, 1])
		for i in range(4):
			if t > n:
				break
			t *= 10
			j += 1
		j -= 1
		print(ans + int(j * (j + 1) / 2))


l = []
for i in range(1, 10):
	for j in range(1, 5):
		l.append(j * str(i))
for _ in range(int(input())):
	n = input()
	x = l.index(n)
	val = sum((len(l[i]) for i in range(x + 1)))
	print(val)


t = int(input())
for i in range(t):
	n = input()
	sum = 0
	for j in range(1, int(n[0]) + 1):
		if j != int(n[0]):
			sum += 10
		else:
			sum += int((1 + len(n)) / 2 * len(n))
	print(sum)


def solve(x):
	i = 0
	res = 0
	while i < len(arr):
		if int(arr[i]) != x:
			res += len(arr[i])
		if int(arr[i]) == x:
			res += len(arr[i])
			return res
		i += 1
arr = []
for i in range(1, 10):
	for j in range(1, 5):
		c = str(i) * j
		arr.append(c)
t = int(input())
while t > 0:
	t -= 1
	x = int(input())
	print(solve(x))


t = int(input())
l = [1, 11, 111, 1111, 2, 22, 222, 2222, 3, 33, 333, 3333, 4, 44, 444, 4444, 5, 55, 555, 5555, 6, 66, 666, 6666, 7, 77, 777, 7777, 8, 88, 888, 8888, 9, 99, 999, 9999]
ct = [1, 2, 3, 4]
while t:
	t -= 1
	n = int(input())
	cnt = 0
	i = 0
	for ele in l:
		cnt += ct[i % 4]
		i += 1
		if ele == n:
			print(cnt)
			break


import sys
input = sys.stdin.buffer.readline
ans = []
for i in range(1, 10):
	ans.append(i)
	ans.append(ans[-1] * 10 + ans[-1])
	ans.append(ans[-1] * 10 + i)
	ans.append(ans[-1] * 10 + i)
for _ in range(int(input())):
	p = 0
	n = int(input())
	for i in ans:
		if i == n:
			p += len(str(i))
			break
		else:
			p += len(str(i))
	print(p)


for ___ in range(int(input())):
	x = input()
	digits = len(x)
	x = int(x[0])
	s = (1 + 2 + 3 + 4) * (x - 1)
	for i in range(digits):
		s += i + 1
	print(s)


cases = int(input())
for i in range(0, cases):
	x = input()
	print(10 * (int(x[0]) - 1) + sum([j for j in range(1, len(x) + 1)]))


for _ in range(int(input())):
	x = int(input())
	result = 0
	for y in range(1, 10):
		cur = y
		keys = 1
		done = False
		for z in range(5):
			if cur > 10000:
				break
			result += keys
			if cur == x:
				break
			cur *= 10
			cur += y
			keys += 1
		if cur == x:
			break
	print(result)


from math import *
from sys import *
t = int(stdin.readline())
for _ in range(t):
	n = int(stdin.readline())
	x = ceil(log10(n))
	if n == 1:
		x = 1
	a = n % 10
	ans = 0
	for i in range(a - 1):
		for j in range(1, 5):
			ans += j
	for i in range(x + 1):
		ans += i
	print(ans)


n = int(input())
abc = [1, 2, 3, 4]
for x in range(n):
	ans = 0
	a = 0
	n = int(input())
	count = 0
	a = int(n % 10)
	b = (a - 1) * 10
	while n > 0:
		count = count + 1
		n = n // 10
	for i in range(count):
		ans = ans + abc[i]
	print(ans + b)


for _ in range(int(input())):
	num = input()
	a = int(num[0])
	b = len(num)
	ans = 10 * (a - 1) + b * (b + 1) // 2
	print(ans)


import sys
input = sys.stdin.readline

def main():
	x = input().strip()
	n = int(x[0])
	l = len(x)
	ans = 10 * (n - 1) + l * (l + 1) // 2
	print(ans)
for _ in range(int(input())):
	main()


for _ in range(int(input())):
	n = input()
	s = int(n[0])
	n = int(n)
	ans = 0
	for i in range(s - 1):
		ans = ans + 10
	for i in range(1, len(str(n)) + 1):
		ans = ans + i
	print(ans)


spisok = []
for i in range(9):
	el = str(i + 1)
	s = ''
	for j in range(4):
		s += el
		spisok.append(s)

def find_ans(a):
	return len(''.join(spisok[:spisok.index(str(a)) + 1]))
n = int(input())
for i in range(n):
	print(find_ans(int(input())))


for _ in range(int(input())):
	x = int(input())
	refer_ = [0, 9, 7, 4, 0]
	l = len(str(x))
	ans = x % 10 * 10 - refer_[l]
	print(ans)


t = int(input())
while t:
	t = t - 1
	x = input()
	count = int((int(x[0]) - 1) * 10 + len(x) * (len(x) + 1) / 2)
	print(count)


from math import *
tc = int(input())
for t in range(tc):
	v = [0, 1, 3, 6, 10]
	a = input()
	b = int(a[0])
	if b == 1:
		print(f'{v[len(a)]}')
	else:
		print(f'{(b - 1) * 10 + v[len(a)]}')


for _ in range(int(input())):
	x = int(input())
	y = x % 10
	ans = 10 * (y - 1)
	for i in range(1, len(str(x)) + 1):
		ans += i
	print(ans)


exec(int(input()) * 's=input();print(10*int(s[0])+len(s)*(len(s)+1)//2-10);')


for t in range(int(input())):
	n = input()
	print(len(n) * (len(n) + 1) // 2 + 10 * (int(n) % 10 - 1))


import sys
input = sys.stdin.readline
from collections import defaultdict as dc
from bisect import bisect_right
import math
for _ in range(int(input())):
	n = int(input())
	x = n % 10
	c = 10 * (x - 1)
	s = str(n)
	for i in range(len(s)):
		c += i + 1
	print(c)


T = int(input())
for _ in range(T):
	x = int(input())
	ans = (int(str(x)[0]) - 1) * 10 + sum([1, 2, 3, 4][:len(str(x))])
	print(ans)


def read_int():
	return int(input())

def solve(key):
	ans = 0
	for str in [a * x for a in ['1', '2', '3', '4', '5', '6', '7', '7', '9'] for x in range(1, 4 + 1)]:
		ans += len(str)
		if str == key:
			break
	return ans

def f(key):
	return sum(range(len(key) + 1)) + 10 * (int(key[0]) - 1)
n = read_int()
for case in range(n):
	s = input()
	print(f(s))


t = int(input())
a = 10
li = [1, 2, 3, 4]
for i in range(0, t):
	count = 0
	s = input()
	b = len(s)
	count = a * (int(s[0]) - 1)
	for j in range(0, b):
		count = count + li[j]
	print(count)


from math import *
t = int(input())
for u in range(t):
	n = int(input())
	x = n % 10
	z = len(str(n))
	z = z * (z + 1) // 2
	print((x - 1) * 10 + z)


for x in range(int(input())):
	a = input()
	s = (int(a[0]) - 1) * 10
	t = len(a)
	s += t * (t + 1) // 2
	print(s)


for _ in range(int(input())):
	n = int(input())
	v = len(str(n))
	x = n // 10 ** (v - 1)
	ans = v * (v + 1) // 2 + (x - 1) * 10
	print(ans)


t = int(input())
while t > 0:
	n = input()
	l = len(n)
	n = n[0]
	print(int((int(n) - 1) * 10 + l * (l + 1) / 2))
	t -= 1


n = int(input())

def val(x):
	return x * (x + 1) // 2
while n:
	res = 0
	a = input()
	res = res + val(len(a))
	res = res + 10 * (int(a[0]) - 1)
	print(res)
	n = n - 1


for _ in range(int(input())):
	x = input()
	(c, s) = (0, 0)
	for i in range(1, 10):
		y = str(i)
		for j in range(1, 5):
			s += j
			if y * j == x:
				c = 1
				break
		if c:
			print(s)
			break


n = int(input())
while n:
	s = '1'
	st = 0
	res = 0
	end = int(input())
	for i in range(1, 10):
		if i == end:
			res += 1
			break
		res += 1
		for j in range(3):
			s = s + str(i)
			res += len(s)
			if int(s) == end:
				st = 1
				break
		if st == 1:
			break
		s = str(i + 1)
	print(res)
	n = n - 1


import sys

def read(func=int):
	return func(sys.stdin.readline().strip())

def readList(func=int):
	return list(map(func, sys.stdin.readline().strip().split()))
t = read()
for _ in range(t):
	num = read()
	tot = (num % 10 - 1) * 10
	for i in range(len(str(num))):
		tot += i + 1
	print(tot)


n = int(input())
while n > 0:
	m = input()
	x = len(m)
	print(int(x * (x + 1) / 2) + 10 * (int(m[0]) - 1))
	n = n - 1


from collections import deque
from collections import Counter
from itertools import permutations
import heapq

def counterExample():
	arr = [1, 3, 4, 1, 2, 1, 1, 3, 4, 3, 5, 1, 2, 5, 3, 4, 5]
	counter = Counter(arr)
	top_three = counter.most_common(3)
	print(top_three)
q = deque()
import math

def main():
	n = int(input())
	while n >= 1:
		count = 0
		x = input()
		count = count + (int(x[0]) - 1) * 10
		nrDigits = len(x)
		for i in range(0, nrDigits + 1):
			count += i
		print(count)
		n -= 1
main()


t = int(input())
while t > 0:
	n = int(input())
	s = str(n)
	maximum = int(max(s))
	lth = len(s)
	if lth == 2:
		another = 3
	elif lth == 3:
		another = 6
	elif lth == 4:
		another = 10
	elif lth == 1:
		another = 1
	ans = 10 * (maximum - 1) + another
	print(ans)
	t = t - 1


t = int(input())
for j in range(t):
	sum = 1
	n = int(input())
	total = 0
	count = 1
	i = 1
	while sum != n:
		if total < 1000:
			sum = sum * 10 + i
			total = sum
			str1 = str(total)
			count += len(str1)
		else:
			i = i + 1
			total = 0
			sum = i
			count += 1
	print(count)


from collections import deque
for tt in range(int(input())):
	x = input()
	r = x[0]
	d = deque()
	for i in range(1, 10):
		if i == int(r):
			break
		else:
			d.append(i)
	res = 10 * len(d)
	if len(x) == 1:
		res += 1
	if len(x) == 2:
		res += 3
	if len(x) == 3:
		res += 6
	if len(x) == 4:
		res += 10
	print(res)


t = int(input())
for i in range(t):
	n = input()
	a = int(n[0])
	r = a * 10
	if len(n) == 4:
		print(r)
	else:
		s = 0
		for i in range(len(n) + 1, 5):
			s += i
		r = r - s
		print(r)


def boring(string):
	number = int(string[0])
	n = len(string)
	ans = 10 * number
	if n == 4:
		return ans
	if n == 3:
		return ans - 4
	if n == 2:
		return ans - 7
	if n == 1:
		return ans - 9
t = int(input())
for i in range(t):
	string = input()
	print(boring(string))


t = int(input())
for _ in range(t):
	n = input()
	num = int(n[0]) - 1
	ans = num * 10
	l = len(n)
	ans += l * (l + 1) // 2
	print(ans)


t = int(input())
for j in range(t):
	x = input()
	l = len(x)
	for i in range(1, 10):
		if int(x[0]) == i:
			y = i
			break
	print(int(10 * (y - 1) + l * (l + 1) / 2))


for _ in range(int(input())):
	n = int(input())
	x = len(str(n))
	y = int(str(n)[0])
	print(int(10 * y - 10 + (x * x + x) / 2))


t = int(input())
l = [str(d) * c for d in range(1, 10) for c in range(1, 5)]
m = []
for ll in l:
	if m:
		m.append(len(ll) + m[-1])
	else:
		m.append(len(ll))
res = []
for _ in range(t):
	x = input()
	res.append(m[l.index(x)])
for r in res:
	print(r)


import heapq as hq
from heapq import heappop, heappush
from collections import deque, defaultdict
from sys import stdin, stdout

def inp():
	return int(stdin.readline())

def inlt():
	return list(map(int, stdin.readline().split()))

def insr():
	return list(stdin.readline().strip())

def invr():
	return map(int, stdin.readline().split())
for _ in range(inp()):
	x = inp()
	s = 0
	s += (x % 10 - 1) * 10
	if len(str(x)) == 1:
		s += 1
	if len(str(x)) == 2:
		s += 3
	if len(str(x)) == 3:
		s += 6
	if len(str(x)) == 4:
		s += 10
	print(s)


q = int(input())
for _ in range(q):
	n = input()
	first = int(n[0])
	if len(n) == 1:
		print((first - 1) * 10 + 1)
	elif len(n) == 2:
		print((first - 1) * 10 + 3)
	elif len(n) == 3:
		print((first - 1) * 10 + 6)
	else:
		print((first - 1) * 10 + 10)


for _ in range(int(input())):
	n = input()
	ap = int(n[0])
	leng = len(n)
	if ap == 1:
		print(leng * (leng + 1) // 2)
	else:
		total = (ap - 1) * 10
		total += leng * (leng + 1) // 2
		print(total)


for _ in range(int(input())):
	end = int(input())
	s = int(str(end)[0])
	print(10 * (s - 1) + (1 + len(str(end))) * len(str(end)) // 2)


def getsum(n):
	return n * (n + 1) // 2
for _ in range(int(input())):
	x = input()
	ans = getsum(len(x)) + (int(x[0]) - 1) * 10
	print(ans)


t = int(input())
for z in range(t):
	x = int(input())
	cnt = 0
	st = False
	for i in range(1, 10):
		num = ''
		if st:
			break
		for j in range(1, 5):
			num += str(i)
			cnt += j
			if int(num) == x:
				st = True
				break
	print(cnt)


a = [1, 11, 111, 1111]
temp = a[:]
x = 2
ans = {}
while x < 10:
	for i in a:
		temp.append(i * x)
	x += 1
for (i, j) in enumerate(temp):
	ans[j] = i
for i in range(int(input())):
	x = int(input())
	num = ans[x]
	sus = [1, 3, 6, 10]
	print(num // 4 * 10 + sus[num % 4])


for _ in range(int(input())):
	a = input().strip()
	x = int(a[0])
	n = len(a)
	print((x - 1) * 10 + n * (n + 1) // 2)


def solve(x):
	digit = x % 10
	digit_count = len(str(x))
	soln = 10 * (digit - 1)
	soln += sum(list(range(1, digit_count + 1)))
	return soln

def main():
	import sys
	test_cases = int(sys.stdin.readline())
	for _ in range(test_cases):
		x = int(sys.stdin.readline())
		print(solve(x))
main()


t = int(input())
for i in range(t):
	num = str(input())
	result = 10 * (int(num[0]) - 1)
	for i in range(1, len(num) + 1):
		result += i
	print(result)


t = int(input())
while t:
	t -= 1
	x = input().strip()
	n = len(x)
	c = int(x[0])
	ans = (c - 1) * 10 + n * (n + 1) // 2
	print(ans)


a = int(input())
g = 1
k = [1]
v = []
for i in range(1, a + 1):
	h = int(input())
	f = 1
	b = 1
	p = 1111
	g = 1
	while f != h:
		if f != h:
			f = f * 10 + b
		if f > p:
			f = g + 1
			b += 1
			g += 1
			p += 1111
		l = k.append(f)
	k = [str(i) for i in k]
	k = ''.join(k)
	k = int(len(k))
	u = v.append(k)
	k = [1]
for i in v:
	print(i)


for k in range(int(input())):
	n = input()
	res = 0
	for i in range(1, 10):
		fl = 0
		for j in range(1, 5):
			res += j
			if n == str(i) * j:
				print(res)
				fl = 1
				break
		if fl:
			break


t = int(input())
for _ in range(t):
	n = int(input())
	last = n % 10
	cur = (last - 1) * 10
	if n < 10:
		print(cur + 1)
	elif n < 100:
		print(cur + 3)
	elif n < 1000:
		print(cur + 6)
	else:
		print(cur + 10)


def solve():
	n = int(input())
	ans = (int(str(n)[0]) - 1) * 10 + len(str(n)) * (len(str(n)) + 1) // 2
	print(ans)
t = int(input())
for i in range(t):
	solve()


t = int(input())
for i in range(t):
	n = int(input())
	a = len(str(n))
	b = n % 10
	k = 0
	for j in range(1, b):
		k += 10
	if a == 1:
		print(k + 1)
	if a == 2:
		print(k + 3)
	if a == 3:
		print(k + 6)
	if a == 4:
		print(k + 10)


t = int(input())
li = []
for i in range(t):
	li.append(int(input()))

def obrabotka(x):
	dlina = len(str(x))
	res = 0
	for i in range(1, int(str(x)[0])):
		res += 10
	for i in range(1, dlina + 1):
		res += i
	return res
answer_list = []
for elem in li:
	answer_list.append(obrabotka(elem))
for elem in answer_list:
	print(elem)


t = int(input())
while t > 0:
	t -= 1
	x2 = int(input())
	l = []
	while x2 > 0:
		l.append(x2 % 10)
		x2 //= 10
	ans = 0
	if l[0] == 1:
		k = len(l)
		while k > 0:
			ans += k
			k -= 1
	else:
		k = len(l)
		while k > 0:
			ans += k
			k -= 1
		ans += 10 * (l[0] - 1)
	print(ans)


import os, sys
from collections import defaultdict, Counter
from io import BytesIO, IOBase

def main():
	for _ in range(int(input())):
		x = int(input())
		an = 0
		an += 10 * (x % 10 - 1)
		p = len(str(x))
		an += p * (p + 1) // 2
		print(an)
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
input = lambda : sys.stdin.readline().rstrip('\r\n')
main()


import sys

def main():
	n = int(input())
	print(n % 10 * 10 + (len(str(n)) + 1) * len(str(n)) // 2 - 10)
for i in range(int(input())):
	main()


t = int(input())
fr = []
for i in range(t):
	y = int(input())
	fr += [y]
for q in range(t):
	nmbr = fr[q]
	ouns = 0
	if nmbr % 10 >= 2:
		ouns += 10
	if nmbr % 10 >= 3:
		ouns += 10
	if nmbr % 10 >= 4:
		ouns += 10
	if nmbr % 10 >= 5:
		ouns += 10
	if nmbr % 10 >= 6:
		ouns += 10
	if nmbr % 10 >= 7:
		ouns += 10
	if nmbr % 10 >= 8:
		ouns += 10
	if nmbr % 10 == 9:
		ouns += 10
	nmbr = str(nmbr)
	b = len(nmbr)
	if b == 1:
		ouns += 1
	if b == 2:
		ouns += 3
	if b == 3:
		ouns += 6
	if b == 4:
		ouns += 10
	print(ouns)


t = int(input())
for i in range(t):
	x = input()
	num = int(x[0]) - 1
	num *= 10
	for i in range(len(x)):
		num += i + 1
	print(num)


A = [1, 3, 6, 10]
t = input()
for i in range(int(t)):
	x = input()
	l = len(x)
	x = int(x)
	x = x % 10
	print((x - 1) * 10 + A[l - 1])


T = int(input())
for t in range(T):
	x = int(input())
	ans = 0
	t = {1: 1, 11: 3, 111: 6, 1111: 10, 2: 11, 22: 13, 222: 16, 2222: 20, 3: 21, 33: 23, 333: 26, 3333: 30, 4: 31, 44: 33, 444: 36, 4444: 40, 5: 41, 55: 43, 555: 46, 5555: 50, 6: 51, 66: 53, 666: 56, 6666: 60, 7: 61, 77: 63, 777: 66, 7777: 70, 8: 71, 88: 73, 888: 76, 8888: 80, 9: 81, 99: 83, 999: 86, 9999: 90}
	print(t[x])


t = int(input())
for i in range(0, t):
	n = int(input())
	l = len(str(n))
	print(10 * (n % 10 - 1) + l * (l + 1) // 2)


def sumation(n):
	if n == 1:
		return 1
	if n == 2:
		return 3
	if n == 3:
		return 6
	if n == 0:
		return 0
	if n == 4:
		return 10
for _ in range(int(input())):
	str = input()
	d = int(str[0])
	n = len(str)
	print(sumation(n) + (d - 1) * 10)


for _ in range(int(input())):
	x = str(input())
	p = len(x)
	dp = {1: 1, 2: 3, 3: 6, 4: 10}
	d = int(x[0])
	print((d - 1) * 10 + dp[p])


t = int(input())
for _ in range(t):
	digit = input()
	num = int(digit[0])
	sum = (num - 1) * 10
	for x in range(len(digit)):
		sum += x + 1
	print(sum)


t = int(input())
while t:
	n = input()
	f = int(n[0])
	ans = (f - 1) * 10
	ans += len(n) * (len(n) + 1) / 2
	print(int(ans))
	t -= 1


for _ in range(int(input())):
	x = input()
	a = 0
	for i in range(1, 10):
		no = 1
		for j in range(1, 5):
			no = str(i) * j
			a += len(str(no))
			if no == x:
				print(a)
				break


for t in range(int(input())):
	x = input()
	ans = []
	for i in range(1, 10):
		for j in range(1, 5):
			ans.append(str(i) * j)
	cnt = 0
	for i in ans:
		if i == x:
			cnt += len(i)
			break
		else:
			cnt += len(i)
	print(cnt)


t = int(input())
w = []
for i in range(t):
	x = input()
	w.append(10 * (int(x[0]) - 1) + len(x) * (len(x) + 1) // 2)
for i in w:
	print(i)


import sys

def get_ints():
	return map(int, sys.stdin.readline().strip().split())

def get_list():
	return list(map(int, sys.stdin.readline().strip().split()))

def get_string():
	return sys.stdin.readline().strip()

def get_int():
	return int(sys.stdin.readline().strip())

def solve():
	for _ in range(get_int()):
		n = get_int()
		ans = 0
		start = '1'
		check = 10 ** 4
		while int(start) != n:
			ans += len(start)
			temp = start + start[0]
			if int(temp) <= check:
				start = temp
			else:
				up = int(start[0]) + 1
				start = str(up)
		print(ans + len(start))
solve()


t = int(input())
for _ in range(t):
	n = int(input())
	x = n % 10
	s = (x - 1) * 10
	i = 0
	while n != 0:
		i += 1
		s = s + i
		n = n // 10
	print(s)


for ct in range(int(input())):
	n = int(input())
	k = n % 10 - 1
	ans = 4 * (4 + 1) // 2 * k
	p = len(str(n))
	p = int(p)
	print(ans + p * (p + 1) // 2)


for t in range(int(input())):
	n = int(input())
	mul = 4
	no = 0
	c = 0
	tri = 0
	f = 0
	for i in range(9):
		c += 1
		no = 0
		for j in range(4):
			no = no * 10 + c
			tri += len(str(no))
			if no == n:
				f = 1
				break
		if f == 1:
			break
	print(tri)


import sys
import math

def get_ints():
	return map(int, sys.stdin.readline().strip().split())

def get_list():
	return list(map(int, sys.stdin.readline().strip().split()))

def get_string():
	return sys.stdin.readline().strip()
for t in range(int(input())):
	n = int(input())
	count = 0
	size = len(str(n))
	broken = 0
	for i in range(1, 10):
		for j in range(1, 5):
			number = str(i) * j
			if int(number) == n:
				broken += 1
				count += j
				break
			else:
				count += j
		if broken > 0:
			break
	print(count)


t = int(input())
for i in range(t):
	x = int(input())
	d = 0
	n = x // 11
	b = x % 10
	if n == 0:
		d = (x - 1) * 10 + 1
	elif n > 0 and n < 10:
		d = (b - 1) * 10 + 3
	elif x % 11 == 0:
		d = b * 10
	else:
		d = (b - 1) * 10 + 6
	print(d)


def solution():
	n = int(input())
	lists = []
	for i in range(1, 10):
		for j in range(1, 5):
			lists.append(int(str(i) * j))
	lists.reverse()
	ans = 0
	v = -1
	while v != n:
		x = lists.pop()
		ans += len(str(x))
		v = x
	print(ans)
	return

def main():
	testcase = int(input())
	for i in range(testcase):
		solution()
	return
main()


for _ in range(int(input())):
	n = int(input())
	str_n = str(n)
	len_n = len(str_n)
	k = int(str_n[0])
	print((k - 1) * 10 + len_n * (len_n + 1) // 2)


def factorial(n):
	if n == 0:
		return 1
	return n * factorial(n - 1)
for _ in range(int(input())):
	n = input()
	l = len(n)
	p = int(n[0])
	sum1 = (p - 1) * 10
	for i in range(1, l + 1):
		sum1 = sum1 + i
	print(sum1)


t = int(input())
for i in range(t):
	x = input()
	ans = (int(x[0]) - 1) * (1 + 2 + 3 + 4)
	ans += len(x) * (len(x) + 1) // 2
	print(ans)


for z in range(int(input())):
	s = input()
	n = (int(s[0]) - 1) * 10 + len(s) * (len(s) + 1) // 2
	print(n)


for i in range(int(input())):
	st = input()
	x = int(st[0])
	print(10 * (x - 1) + len(st) * (len(st) + 1) // 2)


t = int(input())
while t > 0:
	n = input()
	extra = int(n)
	plus = 0
	if extra < 10:
		plus = 1
	elif extra < 100:
		plus = 2
	elif extra < 1000:
		plus = 3
	else:
		plus = 4
	adds = 0
	for i in range(1, plus + 1):
		adds += i
	total = 10 * (int(n[0]) - 1) + adds
	print(total)
	t -= 1


t = int(input())
for i in range(t):
	x = int(input())
	print((int(str(x)[0]) - 1) * 10 + (1 + len(str(x))) * len(str(x)) // 2)


for _ in range(int(input())):
	x = int(input())
	ans = x % 10 * 10
	if x < 10:
		ans = ans - 9
	elif x > 10 and x < 100:
		ans = ans - 7
	elif x > 100 and x < 1000:
		ans = ans - 4
	else:
		ans = ans - 0
	print(ans)


resultados = list()
cases = int(input())
for n in range(cases):
	appart = input()
	appart = list(appart)
	resultado = (int(appart[0]) - 1) * 10
	if len(appart) == 4:
		resultado = resultado + 10
	elif len(appart) == 3:
		resultado = resultado + 6
	elif len(appart) == 2:
		resultado = resultado + 3
	else:
		resultado = resultado + 1
	resultados.append(resultado)
for n in range(len(resultados)):
	print(resultados[n])


t = int(input())
for _ in range(t):
	n = input()
	ans = 0
	for i in range(1, 10):
		s = str(i)
		while s != n and int(s) < 10 ** 4:
			ans += len(s)
			s += str(i)
		if s == n:
			print(ans + len(s))
			break


tc = int(input())
i = 0
out = []
while i < tc:
	count = 0
	num = input()
	i += 1
	li = list(num)
	x = len(li)
	for k in range(int(li[0]) - 1):
		count += 10
	count += x * (x + 1) / 2
	out.append(int(count))
print(*out, sep='\n')


for testcase in range(int(input())):
	boring_number = int(input())
	repeating_digit = boring_number % 10
	digits = 0
	number = boring_number
	while number:
		number //= 10
		digits += 1
	print((1 + 2 + 3 + 4) * (repeating_digit - 1) + 1 * int(bool(max(digits, 0))) + 2 * int(bool(max(digits - 1, 0))) + 3 * int(bool(max(digits - 2, 0))) + 4 * int(bool(max(digits - 3, 0))))


import os
import sys
from math import *
from collections import *
from fractions import *
from heapq import *
from bisect import *
from io import BytesIO, IOBase

def vsInput():
	sys.stdin = open('input.txt', 'r')
	sys.stdout = open('output.txt', 'w')
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
input = lambda : sys.stdin.readline().rstrip('\r\n')
ALPHA = 'abcdefghijklmnopqrstuvwxyz/'
M = 1000000007
EPS = 1e-06

def Ceil(a, b):
	return a // b + int(a % b > 0)

def value():
	return tuple(map(int, input().split()))

def array():
	return [int(i) for i in input().split()]

def Int():
	return int(input())

def Str():
	return input()

def arrayS():
	return [i for i in input().split()]
for _ in range(Int()):
	n = Int()
	ans = (n % 10 - 1) * 10
	k = len(str(n))
	ans += (k + 1) * k // 2
	print(ans)


for _ in range(int(input())):
	a = input()
	print((int(a[0]) - 1) * 10 + sum([i for i in range(1, len(a) + 1)]))


T = int(input())
for _ in range(T):
	n = int(input())
	d = n % 10
	c = 0
	while n:
		c += 1
		n //= 10
	ans = 0
	for i in range(1, d):
		ans += 10
	l = 1
	for j in range(1, c + 1):
		ans += l
		l += 1
	print(ans)


import math
for _ in range(int(input())):
	n = input()
	p = (int(n[0]) - 1) * 10
	p += len(n) * (len(n) + 1) // 2
	print(p)


l = []
for j in range(1, 10):
	l.append(1 * str(j))
	l.append(2 * str(j))
	l.append(3 * str(j))
	l.append(4 * str(j))
for _ in range(int(input())):
	x = int(input())
	j = l.index(str(x))
	s = 0
	for i in range(j + 1):
		s += len(l[i])
	print(s)


t = int(input())
d = {1: 1, 2: 3, 3: 6, 4: 10}
for _ in range(t):
	n = int(input())
	prev = n % 10 - 1
	prev = prev * 10
	cu = d[len(str(n))]
	print(cu + prev)


def f():
	x = int(input())
	e = x % 10
	l = len(str(x))
	a = [-1, 1, 3, 6, 10]
	res = (e - 1) * 10 + a[l]
	print(res)
for i in range(int(input())):
	f()


numInputs = input()
hashmap = {1: 1, 2: 3, 3: 6, 4: 10}
for i in range(0, int(numInputs)):
	apartmentNumber = input()
	print((int(apartmentNumber[0]) - 1) * 10 + hashmap.get(len(apartmentNumber)))


def press_count(num):
	return 10 * (int(num[0]) - 1) + sum([len(num) - i for i in range(len(num))])
for i in range(int(input())):
	print(press_count(input()))


a = int(input())
n = []
for i in range(a):
	b = str(input())
	n.append(b)
for i in n:
	if i[0] == '1':
		k = 0
	if i[0] == '2':
		k = 1
	if i[0] == '3':
		k = 2
	if i[0] == '4':
		k = 3
	if i[0] == '5':
		k = 4
	if i[0] == '6':
		k = 5
	if i[0] == '7':
		k = 6
	if i[0] == '8':
		k = 7
	if i[0] == '9':
		k = 8
	s = len(i)
	if s == 1:
		d = 1
	if s == 2:
		d = 3
	if s == 3:
		d = 6
	if s == 4:
		d = 10
	f = 10 * k + d
	print(f)


times = int(input())

def count(num):
	result = 0
	for letter in range(1, 10):
		result += 1
		if num == letter:
			break
		result += 2
		if num == letter * 11:
			break
		result += 3
		if num == letter * 111:
			break
		result += 4
		if num == letter * 1111:
			break
	return result
for i in range(times):
	num = int(input())
	print(count(num))


def solve(x):
	c = (x % 10 - 1) * 10
	c += len(str(x)) * (len(str(x)) + 1) // 2
	return c
t = int(input())
for i in range(t):
	x = int(input())
	print(solve(x))


def func(n):
	ans = 0
	for i in range(1, n + 1):
		ans += i
	return ans
a = int(input())
val = 10
for _ in range(a):
	n = input()
	if n == '1':
		print(1)
		continue
	if n[0] != '1':
		first = val * (int(n[0]) - 1)
	else:
		first = 0
	second = func(int(len(n)))
	print(first + second)


n = int(input())
for i in range(n):
	number = input()
	count = (int(number[0]) - 1) * 10
	if len(number) == 4:
		count += 10
	elif len(number) == 3:
		count += 6
	elif len(number) == 2:
		count += 3
	else:
		count += 1
	print(count)


tests = int(input())
for test in range(tests):
	n = int(input())
	rounds = n % 10
	x = [1, 11, 111, 1111]
	ans = (rounds - 1) * 10
	for i in range(4):
		if x[i] * rounds <= n:
			ans += i + 1
	print(ans)


for _ in range(int(input())):
	x = input()
	fst = (int(x[0]) - 1) * 10
	lst = 0
	for i in range(1, len(x) + 1):
		lst += i
	print(fst + lst)


for t in range(int(input())):
	x = int(input())
	bad = x % 10
	ans = 10 * (bad - 1)
	ans += len(str(x)) * (len(str(x)) + 1) // 2
	print(ans)


from collections import Counter, OrderedDict
from itertools import permutations as perm
from collections import deque
from sys import stdin
from bisect import *
from heapq import *
import math
g = lambda : stdin.readline().strip()
gl = lambda : g().split()
gil = lambda : [int(var) for var in gl()]
gfl = lambda : [float(var) for var in gl()]
gcl = lambda : list(g())
gbs = lambda : [int(var) for var in g()]
mod = int(1000000000.0) + 7
inf = float('inf')
(t,) = gil()
for _ in range(t):
	s = g()
	dig = int(s[0])
	ans = 10 * (dig - 1)
	n = len(s)
	v = [1, 3, 6, 10]
	ans += v[n - 1]
	print(ans)


d = {1: 1, 2: 3, 3: 6, 4: 10}

def f(k):
	return d[len(k)] + d[4] * (int(k[0]) - 1)
for i in range(int(input())):
	print(f(input()))


testCase = int(input())
result = 0
for i in range(testCase):
	number = int(input())
	result = (number % 10 - 1) * 10
	for i in range(1, len(str(number)) + 1):
		result = result + i
	print(result)


t = input()
t = int(t)
for i in range(t):
	x = input()
	l = len(x)
	x = int(x[0])
	c = 10 * (x - 1) + l * (l + 1) // 2
	print(c)


from math import *
import threading
import sys

def fact(x):
	if x == 0:
		return 1
	else:
		return x * fact(x - 1)

def lower_bound(li, num):
	answer = -1
	start = 0
	end = len(li) - 1
	while start <= end:
		middle = (end + start) // 2
		if li[middle] >= num:
			answer = middle
			end = middle - 1
		else:
			start = middle + 1
	return answer

def upper_bound(li, num):
	answer = -1
	start = 0
	end = len(li) - 1
	while start <= end:
		middle = (end + start) // 2
		if li[middle] <= num:
			answer = middle
			start = middle + 1
		else:
			end = middle - 1
	return answer

def abs(x):
	return x if x >= 0 else -x

def binary_search(li, val, lb, ub):
	ans = -1
	while lb <= ub:
		mid = (lb + ub) // 2
		if li[mid] > val:
			ub = mid - 1
		elif val > li[mid]:
			lb = mid + 1
		else:
			ans = mid
			break
	return ans

def kadane(x):
	sum_so_far = 0
	current_sum = 0
	for i in x:
		current_sum += i
		if current_sum < 0:
			current_sum = 0
		else:
			sum_so_far = max(sum_so_far, current_sum)
	return sum_so_far

def pref(li):
	pref_sum = [0]
	for i in li:
		pref_sum.append(pref_sum[-1] + i)
	return pref_sum

def graph(n, m):
	adj = dict()
	for i in range(1, n + 1):
		adj.setdefault(i, 0)
	for i in range(m):
		(a, b) = map(int, input().split())
		adj[a] += 1
		adj[b] += 1
	return adj

def SieveOfEratosthenes(n):
	prime = [True for i in range(n + 1)]
	p = 2
	li = []
	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, len(prime)):
		if prime[p]:
			li.append(p)
	return li
INF = 1000000000.0
primes = SieveOfEratosthenes(1300000)

def fn(n):
	i = 2
	res = n - 1
	val = 0
	for i in range(int(sqrt(n)) + 1, 1, -1):
		val = i - 1 + int(ceil((n - i) / i))
		if val <= res:
			res = val
		else:
			break
	return res

def solve(a, b, c):
	dis = b ** 2 - 4 * a * c
	ans1 = (-b - sqrt(dis)) / (2 * a)
	print(int(ans1))
	return
li = []
for i in range(1, 10):
	li += [i, i * 11, i * 111, i * 1111]
rem = [0, 1, 3, 6]
for _ in range(int(input())):
	ind = li.index(int(input())) + 1
	ans = ind // 4 * 10
	ans += rem[ind % 4]
	print(ans)


from __future__ import division, print_function
from fractions import Fraction
import sys
import os
from io import BytesIO, IOBase
from itertools import *
import bisect
from heapq import *
from math import ceil, floor
from copy import *
from collections import deque, defaultdict
from collections import Counter as counter
from itertools import combinations
from itertools import permutations as permutate
from bisect import bisect_left as bl
from operator import *
from bisect import bisect_right as br
from bisect import bisect
BUFSIZE = 8192
from sys import stderr

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')

def print(*args, **kwargs):
	(sep, file) = (kwargs.pop('sep', ' '), kwargs.pop('file', sys.stdout))
	at_start = True
	for x in args:
		if not at_start:
			file.write(sep)
		file.write(str(x))
		at_start = False
	file.write(kwargs.pop('end', '\n'))
	if kwargs.pop('flush', False):
		file.flush()
if sys.version_info[0] < 3:
	(sys.stdin, sys.stdout) = (FastIO(sys.stdin), FastIO(sys.stdout))
else:
	(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
from types import GeneratorType

def iterative(f, stack=[]):

	def wrapped_func(*args, **kwargs):
		if stack:
			return f(*args, **kwargs)
		to = f(*args, **kwargs)
		while True:
			if type(to) is GeneratorType:
				stack.append(to)
				to = next(to)
				continue
			stack.pop()
			if not stack:
				break
			to = stack[-1].send(to)
		return to
	return wrapped_func
mod = 1000000007

def inp():
	return sys.stdin.readline().rstrip('\r\n')

def out(var):
	sys.stdout.write(str(var))

def lis():
	return list(map(int, inp().split()))

def stringlis():
	return list(map(str, inp().split()))

def sep():
	return map(int, inp().split())

def strsep():
	return map(str, inp().split())

def fsep():
	return map(float, inp().split())

def nextline():
	out('\n')

def testcase(t):
	for p in range(t):
		solve()

def pow(x, y, p):
	res = 1
	x = x % p
	if x == 0:
		return 0
	while y > 0:
		if y & 1 == 1:
			res = res * x % p
		y = y >> 1
		x = x * x % p
	return res
from functools import reduce

def factors(n):
	return set(reduce(list.__add__, ([i, n // i] for i in range(1, int(n ** 0.5) + 1) if n % i == 0)))

def gcd(a, b):
	if a == b:
		return a
	while b > 0:
		(a, b) = (b, a % b)
	return a

def prefix_sum(ar):
	return list(accumulate(ar))

def suffix_sum(ar):
	return list(accumulate(ar[::-1]))[::-1]

def N():
	return int(inp())
from collections import defaultdict
sys.setrecursionlimit(300000)

def numberOfSetBits(i):
	i = i - (i >> 1 & 1431655765)
	i = (i & 858993459) + (i >> 2 & 858993459)
	return ((i + (i >> 4) & 252645135) * 16843009 & 4294967295) >> 24

def solve():
	n = N()
	l = len(str(n))
	f = n % 10
	print(10 * (f - 1) + l * (l + 1) // 2)
testcase(int(inp()))


import sys, threading
import math
from collections import defaultdict, Counter
input = sys.stdin.readline

def rl(type):
	return [type(w) for w in input().split()]

def reverse(arr):
	return arr[-1::-1]

def mod(a, m):
	return (a % m + m) % m

def check_prime(n):
	temp = int(math.sqrt(n) + 1)
	for i in range(2, temp):
		if n % i == 0:
			return False
	return True

def create_graph(n):
	graph = {}
	for _ in range(n):
		(x, y) = map(int, input().split())
		graph[x].append(y)
		graph[y].append(x)
	return graph

def main():
	l = {1: 1, 2: 3, 3: 6, 4: 10}
	for _ in range(int(input())):
		a = input()[:-1]
		result = (int(a[0]) - 1) * 10 + l[len(a)]
		print(result)
sys.setrecursionlimit(10 ** 6)
threading.stack_size(10 ** 8)
t = threading.Thread(target=main)
t.start()
t.join()


t = int(input())
for i in range(t):
	n = int(input())
	x = n % 10
	a = (x - 1) * 10
	n = str(n)
	print(a + len(n) * (len(n) + 1) // 2)


for s in [*open(0)][1:]:
	n = len(s)
	print(10 * (int(s[0]) - 1) + n * (n - 1) // 2)


import sys, os.path
from collections import *
from heapq import *
from copy import *
import math
mod = 10 ** 9 + 7
if os.path.exists('input.txt'):
	sys.stdin = open('input.txt', 'r')
	sys.stdout = open('output.txt', 'w')
for t in range(int(input())):
	n = int(input())
	s = str(n)
	k = len(s)
	a = int(s[0])
	ans = (a - 1) * 10 + k * (k + 1) // 2
	print(ans)


import math, sys, os
from io import BytesIO, IOBase
mod = 10 ** 9 + 7
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
input = lambda : sys.stdin.readline().rstrip('\r\n')

def minp():
	return map(int, sys.stdin.readline().rstrip().split())

def linp():
	return list(map(int, sys.stdin.readline().rstrip().split()))

def inp():
	return int(input())

def print_list(l):
	print(' '.join(map(str, l)))
for _ in range(inp()):
	n = inp()
	add = (n % 10 - 1) * (4 * 5 // 2)
	s = len(str(n))
	print(add + s * (s + 1) // 2)


for i in range(int(input())):
	a = int(input())
	ans = (a % 10 - 1) * 10
	for j in range(1, len(str(a)) + 1):
		ans += j
	print(ans)


for _ in range(int(input())):
	v = input()
	p = int(v[0]) - 1
	k = len(v)
	ans = p * 10 + k * (k + 1) // 2
	print(ans)


for t in range(int(input())):
	x = input()
	n = int(x[0])
	l = len(x)
	print((n - 1) * 10 + l * (l + 1) // 2)


a = int(input())
for k in range(a):
	b = input()
	c = int(b[0])
	d = len(b)
	sum = 0
	sum = 10 * (c - 1)
	if d == 1:
		print(sum + 1)
	elif d == 2:
		print(sum + 3)
	elif d == 3:
		print(sum + 6)
	else:
		print(sum + 10)


for _ in range(int(input())):
	s = input()
	d = int(s[0])
	cnt = 10 * (d - 1)
	for i in range(1, len(s) + 1):
		cnt += i
	print(cnt)


for i in range(int(input())):
	number = input()
	s = 10
	d = [1, 2, 3, 4]
	n = len(number)
	m = int(number[0])
	total = s * (m - 1)
	total += sum(d[:n])
	print(total)


s = []
for i in range(1, 10):
	for j in range(1, 5):
		s.append(str(i) * j)

def solve(n):
	ans = 0
	for i in s:
		ans += len(i)
		if i == n:
			return ans
for _ in range(int(input())):
	print(solve(input()))


game = int(input())
for i in range(game):
	n = input()
	k = list(n)
	z = 10 * int(k[0]) - 10
	if len(k) == 4:
		print(z + 10)
	elif len(k) == 3:
		print(z + 6)
	elif len(k) == 2:
		print(z + 3)
	else:
		print(z + 1)


r = [1, 11, 111, 1111, 2, 22, 222, 2222, 3, 33, 333, 3333, 4, 44, 444, 4444, 5, 55, 555, 5555, 6, 66, 666, 6666, 7, 77, 777, 7777, 8, 88, 888, 8888, 9, 99, 999, 9999]

def solve(a):
	ans = 0
	for i in r:
		if i == a:
			ans += len(str(i))
			break
		ans += len(str(i))
	print(ans)
for _ in range(int(input())):
	a = int(input())
	solve(a)


t = int(input())
for _ in range(t):
	x = int(input())
	n = len(str(x))
	d = x % 10
	kp = 10 * (d - 1) + int(n * (n + 1) / 2)
	print(kp)


n = int(input())
for i in range(n):
	m = int(input())
	a = m % 10
	s = 10 * (a - 1)
	m = list(map(str, str(m)))
	b = len(m)
	s = s + int(b * (b + 1) / 2)
	print(s)


def si():
	return str(input())

def ii():
	return int(input())

def mi():
	return map(int, input().split())

def li():
	return list(mi())
t = int(input())
for _ in range(t):
	n = si()
	print(int(10 * (int(n[0]) - 1) + 0.5 * len(n) * (len(n) + 1)))


def func(n):
	m = str(n)
	num = len(m)
	first = int(m[0])
	ans = (first - 1) * 10 + num * (num + 1) // 2
	print(ans)
t = int(input())
for _ in range(t):
	n = int(input())
	func(n)


t = int(input())
for _ in range(t):
	x = input()
	erg = 0
	for i in range(1, len(x) + 1):
		erg += i
	x = int(x[0])
	for i in range(x - 1):
		erg += 10
	print(erg)


v = []
for i in range(1, 10):
	for j in range(1, 5):
		v.append(str(i) * j)
for i in range(int(input())):
	n = int(input())
	ans = 0
	for k in range(len(v)):
		ans += len(v[k])
		if n == int(v[k]):
			break
	print(ans)


try:
	t = int(input())
	for i in range(t):
		n = int(input())
		a = n % 10
		c = 0
		while n != 0:
			c += 1
			n = n // 10
		c = c * (c + 1) // 2
		res = c + (a - 1) * 10
		print(res)
except:
	pass


for _ in range(int(input())):
	n = input()
	s = 0
	for i in range(1, int(n[0])):
		s = s + 10
	if len(n) == 4:
		print(s + 10)
	elif len(n) == 3:
		print(s + 6)
	elif len(n) == 2:
		print(s + 3)
	else:
		print(s + 1)


n = int(input())
mas = [0, 1, 3, 6, 10]
for i in range(n):
	x = input()
	print((int(x[0]) - 1) * 10 + mas[len(x)])


k = int(input())
while k != 0:
	k -= 1
	x = input()
	if len(x) == 1:
		a = 1
	if len(x) == 2:
		a = 3
	if len(x) == 3:
		a = 6
	if len(x) == 4:
		a = 10
	print(10 * (int(x) % 10 - 1) + a)


t = []
t = int(input())
for k in range(t):
	x = str(input())
	result = 0
	while int(x[0]) != 0:
		result += len(x)
		if len(x) == 1 and int(x[0]) != 0:
			x = str(int(x[0]) - 1) * 4
		else:
			x = x[0:len(x) - 1]
	print(result)


def solve(x):
	res = 0
	x = str(x)
	_ = int(x[0])
	limit = _ - 1
	for i in range(1, len(x) + 1):
		res += i
	return res + limit * 10
t = int(input())
for i in range(t):
	x = int(input())
	print(solve(x))


from math import *
from collections import deque
from copy import deepcopy
import sys

def inp():
	return sys.stdin.readline().rstrip('\r\n')

def multi():
	return map(int, input().split())

def strmulti():
	return map(str, inp().split())

def lis():
	return list(map(int, inp().split()))

def lcm(a, b):
	return a * b // gcd(a, b)

def ncr(n, r):
	return factorial(n) // (factorial(r) * factorial(max(n - r, 1)))

def stringlis():
	return list(map(str, inp().split()))

def out(var):
	sys.stdout.write(str(var))

def printlist(a):
	print(' '.join((str(a[i]) for i in range(len(a)))))

def isPrime(n):
	if n <= 1:
		return False
	if n <= 3:
		return True
	if n % 2 == 0 or n % 3 == 0:
		return False
	i = 5
	while i * i <= n:
		if n % i == 0 or n % (i + 2) == 0:
			return False
		i = i + 6
	return True
t = int(input())
for _ in range(t):
	n = int(inp())
	check = str(n)
	num = n % 10 - 1
	print(num * 10 + len(check) * (len(check) + 1) // 2)


for i in range(int(input())):
	t = int(input())
	l = [1, 11, 111, 1111, 2, 22, 222, 2222, 3, 33, 333, 3333, 4, 44, 444, 4444, 5, 55, 555, 5555, 6, 66, 666, 6666, 7, 77, 777, 7777, 8, 88, 888, 8888, 9, 99, 999, 9999]
	k = l.index(t)
	k = k + 1
	ans = 0
	q = k // 4
	ans = ans + 10 * q
	r = k % 4
	if r == 1:
		ans = ans + 1
	elif r == 2:
		ans = ans + 3
	elif r == 3:
		ans = ans + 6
	print(ans)


import sys
n = int(input())
a = []
for i in range(n):
	a.append(int(input()))
counter = 0
for k in a:
	breaker = 0
	counter = 0
	for i in range(1, 10, 1):
		if breaker == 0:
			for j in range(1, 5, 1):
				if breaker == 0:
					counter += j
					if str(k)[0] == str(i) and j == len(str(k)):
						print(counter)
						breaker = 1
				else:
					break
		else:
			break


a = [1, 2, 3, 4, 1, 2, 3, 4, 1, 2, 3, 4, 1, 2, 3, 4, 1, 2, 3, 4, 1, 2, 3, 4, 1, 2, 3, 4, 1, 2, 3, 4, 1, 2, 3, 4]
b = [1, 11, 111, 1111, 2, 22, 222, 2222, 3, 33, 333, 3333, 4, 44, 444, 4444, 5, 55, 555, 5555, 6, 66, 666, 6666, 7, 77, 777, 7777, 8, 88, 888, 8888, 9, 99, 999, 9999]
c = int(input())
for i in range(c):
	d = int(input())
	e = 0
	g = b.index(d)
	for j in range(0, g + 1):
		e += a[j]
	print(e)


from sys import stdin, stdout

def INPUT():
	return list((int(i) for i in stdin.readline().split()))
import math

def inp():
	return stdin.readline()

def out(x):
	return stdout.write(x)
import math as M
MOD = 10 ** 9 + 7
from random import randint as R
for _ in range(int(input())):
	n = int(input())
	s = str(n)
	l = len(s)
	f = int(s[0])
	print(10 * (f - 1) + (l ** 2 + l) // 2)


class Solution:

	def appartments(self, n):
		tns = n % 10 - 1
		totalDig = 0
		while n > 0:
			n //= 10
			totalDig += 1
		res = tns * 10
		for i in range(1, 5):
			res += i
			if totalDig == i:
				break
		return res
for _ in range(int(input())):
	res = Solution().appartments(int(input()))
	print(res)


def main():
	t = int(input())
	for i in range(t):
		x = input()
		previous = (int(x[0]) - 1) * 10
		now = sum([i for i in range(1, len(x) + 1)])
		print(previous + now)
main()


t = int(input())
for a in range(t):
	n = input()
	k = int(n[0])
	l = len(n)
	print((k - 1) * 10 + l * (l + 1) // 2)


t = int(input())
for _ in range(t):
	n = input()
	digit = int(n[0])
	keys = (digit - 1) * 10
	l = len(n)
	keys += l * (l + 1) // 2
	print(keys)


import sys
input = lambda : sys.stdin.readline().rstrip()
for _ in range(int(input())):
	n = int(input())
	a = []
	for i in range(1, 10):
		a += [str(i) * j for j in range(1, 5)]
	ans = 0
	for i in range(len(a)):
		ans += len(a[i])
		if int(a[i]) == n:
			break
	print(ans)


try:
	T = int(input())
	for i in range(T):
		n = int(input())
		string = str(n)
		find_rows = int(string[0]) - 1
		sub1 = 10 * find_rows
		k = len(string)
		sub2 = k * (k + 1) // 2
		res = sub1 + sub2
		print(res)
except:
	pass


t = int(input())
for g in range(t):
	n = int(input())
	x = n % 10
	y = (x - 1) * 10
	c = 0
	while n > 0:
		n //= 10
		c += 1
	y += c * (c + 1) // 2
	print(y)


for _ in range(int(input())):
	n = input()
	N = len(n)
	ans = (int(n[0]) - 1) * 10 + N * (N + 1) // 2
	print(ans)


t = int(input())
for i in range(t):
	x = int(input())
	l = [1, 11, 111, 1111]
	if x < 10:
		d = x
	else:
		d = x % 10
	press = (d - 1) * 10
	for i in range(len(l)):
		if x / l[i] == d:
			pos = i + 1
	press = press + pos * (pos + 1) // 2
	print(press)


def cifri(a):
	c = 0
	while a > 0:
		c += 1
		a = a // 10
	return c
for _ in range(int(input())):
	x = int(input())
	n = (x % 10 - 1) * 10
	summ = 0
	for i in range(1, cifri(x) + 1):
		summ += i
	ans = summ + n
	print(ans)


for _ in range(int(input())):
	x = input().strip()
	print((int(x[0]) - 1) * 10 + (0, 1, 3, 6, 10)[len(x)])


t = int(input())
for _ in range(t):
	ans = 0
	num = input()
	(fir, level) = (int(num[0]), len(num))
	ans = 10 * (fir - 1)
	for i in range(len(num)):
		ans += i + 1
	print(ans)


for something in range(int(input())):
	x = input()
	print((int(x[0]) - 1) * 10 + [1, 3, 6, 10][int(len(x) - 1)])


cases = int(input())
for i in range(cases):
	answer = int(input())
	keyPresses = 0
	done = False
	for x in range(1, 10):
		for y in range(1, 5):
			f = int(str(x) * y)
			keyPresses += y
			if f == answer:
				done = True
				break
		if done:
			break
	print(keyPresses)


t = int(input())
for i in range(t):
	num = int(input())
	k = num % 10
	count = 0
	for j in range(1, k):
		count += 10
	for c in range(1, len(str(num)) + 1):
		count += c
	print(count)


for tc in range(int(input())):
	n = input()
	length = len(n)
	num = int(n[0])
	count = 0
	iter = 4 * (num - 1) + length
	flag = 0
	while flag == 0:
		for i in range(1, 5):
			count += i
			iter -= 1
			if iter == 0:
				print(count)
				flag = 1
				break


a = int(input())
L = [input() for i in range(a)]
d = ['0', '1', '3', '6', '10']
for num in L:
	n = (int(num[0]) - 1) * 10 + int(d[len(num)])
	print(n)


t = input()
for k in range(int(t)):
	h = input()
	s = 0
	for x in range(int(h[0]) - 1):
		for i in range(1, 5):
			s = s + i
	for j in range(len(h)):
		s = s + j + 1
	print(s)


x = int(input())
for i in range(x):
	inp = int(input())
	n = 1
	c = 2
	sumValue = 1
	if inp < 10000:
		while True:
			while n < 10000:
				if n == inp:
					break
				numStr = str(n)[0] * c
				if len(numStr) != 5:
					sumValue += len(numStr)
				n = int(numStr)
				c += 1
			if n == inp:
				break
			c = 2
			n = int(str(n)[0]) + 1
			sumValue += 1
	else:
		sumValue = 0
	print(sumValue)


import sys
import math

def get_array():
	return list(map(int, sys.stdin.readline().strip().split()))

def get_ints():
	return map(int, sys.stdin.readline().strip().split())

def input():
	return sys.stdin.readline().strip()
for _ in range(int(input())):
	x = int(input())
	y = str(x)
	a = (int(y[0]) - 1) * 10
	if len(y) == 1:
		print(a + 1)
	elif len(y) == 2:
		print(a + 3)
	elif len(y) == 3:
		print(a + 6)
	else:
		print(a + 10)


import time, math as mt, bisect, sys
from sys import stdin, stdout
from collections import deque
from fractions import Fraction
from collections import Counter
from collections import OrderedDict
pi = 3.141592653589793

def II():
	return int(stdin.readline())

def IO():
	return stdin.readline()

def IP():
	return map(int, stdin.readline().split())

def L():
	return list(map(int, stdin.readline().split()))

def P(x):
	return stdout.write(str(x) + '\n')

def PI(x, y):
	return stdout.write(str(x) + ' ' + str(y) + '\n')

def lcm(a, b):
	return a * b // gcd(a, b)

def gcd(a, b):
	if a == 0:
		return b
	elif b == 0:
		return a
	if a > b:
		return gcd(a % b, b)
	else:
		return gcd(a, b % a)

def bfs(adj, v):
	visited = [False] * (v + 1)
	q = deque()
	while q:
		pass

def sieve():
	li = [True] * 1000001
	(li[0], li[1]) = (False, False)
	for i in range(2, len(li), 1):
		if li[i] == True:
			for j in range(i * i, len(li), i):
				li[j] = False
	prime = []
	for i in range(1000001):
		if li[i] == True:
			prime.append(i)
	return prime

def setBit(n):
	count = 0
	while n != 0:
		n = n & n - 1
		count += 1
	return count
mx = 10 ** 7
spf = [mx] * (mx + 1)

def SPF():
	spf[1] = 1
	for i in range(2, mx + 1):
		if spf[i] == mx:
			spf[i] = i
			for j in range(i * i, mx + 1, i):
				if i < spf[j]:
					spf[j] = i
	return

def readTree(v):
	adj = [set() for i in range(v + 1)]
	for i in range(v - 1):
		(u1, u2) = In()
		adj[u1].add(u2)
		adj[u2].add(u1)
	return adj
mod = 10 ** 9 + 7

def dig(n):
	cnt = 0
	while n > 0:
		n = n // 10
		cnt += 1
	return cnt

def solve():
	li = [1, 11, 111, 1111, 2, 22, 222, 2222, 3, 33, 333, 3333, 4, 44, 444, 4444, 5, 55, 555, 5555, 6, 66, 666, 6666, 7, 77, 777, 7777, 8, 88, 888, 8888, 9, 99, 999, 9999]
	n = II()
	ans = 0
	for ele in li:
		ans += dig(ele)
		if n == ele:
			break
	print(ans)
	return
t = II()
for i in range(t):
	solve()


for _ in range(int(input())):
	n = input()
	k = len(n)
	p = n[0]
	c = 0
	for i in range(int(p) - 1):
		c += 10
	print(c + k * (k + 1) // 2)


a = int(input())
compt = 0
for i in range(a):
	b = int(input())
	if b < 10:
		compt = 10 * (b % 10 - 1) + 1
	elif b < 100:
		compt = 10 * (b % 10 - 1) + 3
	elif b < 1000:
		compt = 10 * (b % 10 - 1) + 6
	else:
		compt = 10 * (b % 10)
	print(compt)


def check(n):
	length = len(n)
	current = length * (2 + (length - 1)) // 2
	previous = (int(n[0]) - 1) * 10
	return current + previous
n = int(input())
for _ in range(n):
	print(check(input()))


t = int(input())
for test_case in range(t):
	n = [int(x) for x in input().split()]
	n = n[0]
	res = 0
	n = str(n)
	res += 10 * (int(n[-1]) - 1)
	if len(n) == 1:
		plus = 1
	elif len(n) == 2:
		plus = 3
	elif len(n) == 3:
		plus = 6
	else:
		plus = 10
	res += plus
	print()
	print(res)
	print()


test_cases = int(input())
boring = list()
x = ''
for i in range(9):
	for j in range(4):
		x += str(i + 1)
		boring.append(x)
	x = ''
for _ in range(test_cases):
	res = ''
	answ = input()
	for i in range(boring.index(answ) + 1):
		res += boring[i]
	print(len(res))


def solve(n):
	m = 10000
	ans = 0
	ans = 10 * (n % 10 - 1)
	for i in range(1, 5):
		ans += i
		n //= 10
		if not n:
			break
	return ans
t = int(input())
while t:
	n = int(input())
	print(solve(n))
	t -= 1


t = int(input())
for test in range(t):
	x = int(input())
	a = len(str(x))
	print((x % 10 - 1) * 10 + a * (a + 1) // 2)


T = int(input())
for t in range(T):
	s = input()
	digit = int(s[0])
	dist = len(s)
	tot = 0
	for row in range(digit - 1):
		tot += 10
	for col in range(dist):
		tot += col + 1
	print(tot)


for _ in range(int(input())):
	ans = 0
	x = int(input())
	if x // 10 == 0:
		ans = (x % 10 - 1) * 10 + 1
	elif x // 100 == 0:
		ans = (x % 10 - 1) * 10 + 3
	elif x // 1000 == 0:
		ans = (x % 10 - 1) * 10 + 6
	else:
		ans = x % 10 * 10
	print(ans)


t = int(input())
for i in range(t):
	n = input()
	l = len(n)
	a = int(n[0])
	p = int((a - 1) * 10 + l * (l + 1) / 2)
	print(p)


t = int(input())
ip = []
for i in range(t):
	ip.append(input())
results = []
for i in range(t):
	if len(ip[i]) > 0:
		(factor, n, temp) = (int(ip[i][0]), len(ip[i]), 0)
		for i in range(1, 5):
			if n > 0:
				temp += factor * i
			else:
				temp += (factor - 1) * i
			n -= 1
		results.append(temp)
	else:
		results.append(0)
for i in results:
	print(i)


l = []
for i in range(1, 9 + 1):
	temp = str(i)
	for j in range(4):
		l.append(temp)
		temp += str(i)
for _ in range(int(input())):
	n = int(input())
	cou = 0
	for i in l:
		if int(i) == n:
			cou += len(i)
			print(cou)
		else:
			cou += len(i)


t = int(input())
for you in range(t):
	n = int(input())
	x = n
	ans = 0
	done = 0
	for i in range(1, 10):
		curr = 0
		for j in range(1, 5):
			curr = curr * 10 + i
			if curr != x:
				ans += j
			else:
				ans += j
				done = 1
				break
		if done:
			break
	print(ans)


for _ in range(0, int(input())):
	x = input()
	y = len(x)
	s = 0
	z = int(x[0]) - 1
	s = s + 10 * z
	i = 1
	while y:
		s = s + i
		i = i + 1
		y = y - 1
	print(s)


t = int(input())
for ii in range(t):
	x = input()
	d = int(x[0])
	count = 0
	for i in range(len(x)):
		count += d * (i + 1)
	for i in range(len(x), 4):
		count += (d - 1) * (i + 1)
	print(count)


t = int(input())
for _ in range(t):
	n = int(input())
	x = list(str(n))
	ans = int(x[0])
	ans -= 1
	ans = ans * 10
	for i in range(1, len(x) + 1):
		ans += i
	print(ans)


n = int(input())
s = []
for i in range(n):
	a = int(input())
	l = len(str(a))
	k = a % 10
	s.append((k - 1) * 10 + l * (l + 1) / 2)
for i in s:
	print(int(i))


for _ in range(int(input())):
	x = input()
	leng = len(x)
	sum = 0
	for i in range(1, leng + 1):
		sum += i
	sum = sum + 10 * (int(x[0]) - 1)
	print(sum)


t = int(input())

def sum_n(n):
	return int(n * (n + 1) / 2)
for _ in range(t):
	num = [int(x) for x in input()]
	if num[0] == 1:
		print(sum_n(len(num)))
	else:
		print((num[0] - 1) * sum_n(4) + sum_n(len(num)))


for cnt in range(int(input())):
	x = int(input())
	d = x % 10
	l = 1
	res = 0
	for i in range(1, d):
		res += 10
	while l <= len(str(x)):
		res += l
		l += 1
	print(res)


t = int(input())
sum = 0
while t > 0:
	n = int(input())
	str_n = str(n)
	(length, first) = (len(str_n), n % 10)
	sum = (first - 1) * 10
	sum += length * (length + 1) // 2
	print(sum)
	t -= 1


import sys, os.path

def mod():
	return 1000000007

def ii():
	return int(sys.stdin.readline())

def si():
	return sys.stdin.readline().strip()

def li():
	return list(sys.stdin.readline().strip())

def mii():
	return map(int, sys.stdin.readline().split())

def lii():
	return list(map(int, sys.stdin.readline().strip().split()))
for i in range(ii()):
	a = ii()
	x = a % 10 - 1
	y = len(str(a))
	z = y * (1 + y) // 2
	print(x * 10 + z)


t = int(input())
for i in range(t):
	x = int(input())
	p = x % 10
	if x > 1000:
		n = 10
	elif x > 100:
		n = 6
	elif x > 10:
		n = 3
	else:
		n = 1
	print((p - 1) * 10 + n)


from sys import stdin, stdout
from collections import Counter
from itertools import permutations
import bisect
import math
I = lambda : map(int, stdin.readline().split())
I1 = lambda : stdin.readline()
for _ in range(int(I1())):
	s = I1().strip()
	x = int(s[0])
	l = len(s)
	print(10 * (x - 1) + l * (l + 1) // 2)


n = int(input())
for i in range(n):
	x = int(input())
	a = x % 10
	b = a - 1
	c = b * 10
	t = str(x)
	if len(t) == 1:
		m = 1
	elif len(t) == 2:
		m = 3
	elif len(t) == 3:
		m = 6
	else:
		m = 10
	print(m + c)


t = int(input())
for i in range(t):
	n = int(input())
	r = n % 10
	ans = (r - 1) * 10
	c = len(str(n))
	ans = int(ans + c * (c + 1) / 2)
	print(ans)


t = int(input())
for i in range(t):
	n = input()
	pos = int(n[0])
	length = len(n)
	ans = 0
	ans = 10 * (pos - 1)
	for j in range(length):
		ans += j + 1
	print(ans)


t = int(input())
for _ in range(t):
	x = input()
	k = x[0]
	sm = 0
	sm += int(k) * 10
	if int(x) < int(k * 2):
		sm -= 9
	elif int(x) < int(k * 3):
		sm -= 7
	elif int(x) < int(k * 4):
		sm -= 4
	print(sm)


for case in range(int(input())):
	x = input()
	ans = (int(x[0]) - 1) * 10
	if len(x) >= 1:
		ans += 1
	if len(x) >= 2:
		ans += 2
	if len(x) >= 3:
		ans += 3
	if len(x) >= 4:
		ans += 4
	print(ans)


for _ in range(int(input())):
	x = int(input())
	k = 10 * (int(str(x)[0]) - 1)
	for i in range(len(str(x)) + 1):
		k += i
	print(k)


import sys

def input():
	return sys.stdin.readline().strip()

def list2d(a, b, c):
	return [[c for j in range(b)] for i in range(a)]

def list3d(a, b, c, d):
	return [[[d for k in range(c)] for j in range(b)] for i in range(a)]

def list4d(a, b, c, d, e):
	return [[[[e for l in range(d)] for k in range(c)] for j in range(b)] for i in range(a)]

def ceil(x, y=1):
	return int(-(-x // y))

def INT():
	return int(input())

def MAP():
	return map(int, input().split())

def LIST(N=None):
	return list(MAP()) if N is None else [INT() for i in range(N)]

def Yes():
	print('Yes')

def No():
	print('No')

def YES():
	print('YES')

def NO():
	print('NO')
INF = 10 ** 19
MOD = 10 ** 9 + 7
EPS = 10 ** (-10)
ans = {}
num = 0
for d in range(1, 10):
	for ln in range(1, 5):
		x = str(d) * ln
		num += ln
		ans[x] = num
for _ in range(INT()):
	x = input()
	print(ans[x])


import sys
t = int(input())
for tc in range(t):
	string = input()
	n = int(string[0]) - 1
	ans = n * 10
	ans += len(string) * (len(string) + 1) // 2
	print(ans)


import sys
import math
import itertools
import copy
import collections
input = sys.stdin.readline

def pr(x, ans):
	print('Case', '#', end='', sep=' ')
	print(x, end='')
	print(':', end=' ')
	print(ans)
T = int(input())
for case in range(T):
	x = input()
	x = x[:-1]
	ans = 0
	for i in range(1, 10):
		flag = False
		ans += 1
		s = str(i)
		if x == s:
			break
		for j in range(2, 5):
			ans += j
			s = str(i) * j
			if s == x:
				flag = True
				break
		if flag:
			break
	print(ans)


for case in range(int(input())):
	x = input()
	ans = (int(x[0]) - 1) * 10
	for i in range(1, len(x) + 1):
		ans += i
	print(ans)


t = int(input())
for _ in range(t):
	n = int(input())
	m = n
	x = str(m)
	for i in range(9, 0, -1):
		if n % i == 0 and int(x[0]) == i:
			a = str(n)
			b = len(a)
			if b == 1:
				print((i - 1) * 10 + 1)
				break
			elif b == 2:
				print((i - 1) * 10 + 3)
				break
			elif b == 3:
				print((i - 1) * 10 + 6)
				break
			elif b == 4:
				print((i - 1) * 10 + 10)
				break


t = int(input())
for _ in range(t):
	x = int(input())
	s = str(x)
	z = int(s[0])
	k = len(s)
	a = 10 * (z - 1) + k * (k + 1) // 2
	print(a)


import math
t = int(input())
for i in range(t):
	x = int(input())
	digits = int(math.log10(x)) + 1
	num = x % 10
	result = (num - 1) * 10
	result = result + digits * (digits + 1) / 2
	print(int(result))


import sys
input = sys.stdin.readline

def solve():
	n = int(input())
	ans = 0
	flag = 0
	for i in range(1, 10):
		total = 0
		for j in range(4):
			total = total * 10 + i
			ans += j + 1
			if total == n:
				return ans
for _ in range(int(input())):
	print(solve())


N = int(input())
for _ in range(N):
	t = input()
	ans = 0
	flag = True
	for i in range(1, 10):
		for j in range(1, 5):
			if flag:
				if t == str(i) * j:
					flag = False
					ans += j
				else:
					ans += j
	print(ans)


t = int(input())
for i in range(t):
	n = input().strip()
	if n[0] == '1':
		if len(n) == 1:
			print('1')
		if len(n) == 2:
			print('3')
		if len(n) == 3:
			print('6')
		if len(n) == 4:
			print('10')
	elif n[0] != '1':
		if len(n) == 1:
			print((int(n[0]) - 1) * 10 + 1)
		if len(n) == 2:
			print((int(n[0]) - 1) * 10 + 3)
		if len(n) == 3:
			print((int(n[0]) - 1) * 10 + 6)
		if len(n) == 4:
			print((int(n[0]) - 1) * 10 + 10)


f = [1, 11, 111, 1111, 2, 22, 222, 2222, 3, 33, 333, 3333, 4, 44, 444, 4444, 5, 55, 555, 5555, 6, 66, 666, 6666, 7, 77, 777, 7777, 8, 88, 888, 8888, 9, 99, 999, 9999]
for _ in range(int(input())):
	l = int(input())
	o = sum((len(str(i)) for i in f[:f.index(l) + 1]))
	print(o)


for _ in range(int(input())):
	n = input()
	fst = int(n[0]) - 1
	ans = 10 * fst + [1, 3, 6, 10][len(n) - 1]
	print(ans)


t = int(input())
for t in range(t):
	q = int(input())
	p = str(q)
	q1 = 10
	q1 *= int(p[0]) - 1
	q1 += len(p) * (len(p) + 1) // 2
	print(q1)


for i in range(int(input())):
	n = input()
	nl = len(n)
	fn = int(n[0])
	r = 10 * (fn - 1) + nl * (nl + 1) // 2
	print(r)


t = int(input())
for i in range(t):
	a = int(input())
	n = a % 10
	d = len(str(a))
	ans = 10 * (n - 1)
	for i in range(d):
		ans += i + 1
	print(ans)


def main():
	t = int(input())
	for i in range(t):
		n = input()
		level = int(n[0]) - 1
		k = len(n)
		out = level * 10 + sum(range(k + 1))
		print(out)
main()


t = int(input())
res = []
for i in range(t):
	res1 = 0
	num = int(input())
	num1 = str(num)
	kol = len(num1) + 4 * (int(num1[0]) - 1)
	j = 1
	for i in range(kol):
		if j <= 4:
			res1 += j
			j += 1
		else:
			res1 += 1
			j = 2
	res.append(res1)
for i in range(len(res)):
	print(res[i])


t = int(input(''))
for _ in range(t):
	x = input('')
	y = int(x[0])
	l = len(x)
	ans = (y - 1) * 10
	ans += l * (l + 1) // 2
	print(ans)


import string
loopnumber = int(input())
while loopnumber > 0:
	picker = int(input())
	power = 1
	i = 1
	numberOfKeys = 1
	t = 1
	while i < 10:
		if picker == t:
			if power == 0:
				numberOfKeys += 1
			print(numberOfKeys)
			break
		elif power == 4:
			i += 1
			t = i
			power = 0
		else:
			if power == 0:
				numberOfKeys += 1
				power = 1
				continue
			t = t + i * 10 ** power
			power += 1
			numberOfKeys += power
	loopnumber -= 1


for i in range(int(input())):
	s = input()
	g = int(s)
	k = int(len(s))
	print((g % 10 - 1) * 10 + int(k * (k + 1) / 2))


num = [1, 11, 111, 1111, 2, 22, 222, 2222, 3, 33, 333, 3333, 4, 44, 444, 4444, 5, 55, 555, 5555, 6, 66, 666, 6666, 7, 77, 777, 7777, 8, 88, 888, 8888, 9, 99, 999, 9999]
mod = [0, 1, 3, 6]
t = int(input())
for i in range(t):
	cnt = 0
	n = int(input())
	for j in num:
		cnt += 1
		if j == n:
			break
	res = cnt // 4
	res2 = cnt % 4
	print(res * 10 + mod[res2])


t = int(input())
for _ in range(t):
	x = str(input())
	first = int(x[0])
	n = len(x)
	res = (first - 1) * 10
	res += n * (1 + n) // 2
	print(res)


l = int(input())
while l:
	n = str(input())
	y = len(n)
	c = int(n[0]) - 1
	if y == 2:
		y = 3
	elif y == 3:
		y = 6
	elif y == 4:
		y = 10
	print(int(c) * 10 + y)
	l -= 1


import sys
input = sys.stdin.readline
I = lambda : list(map(int, input().split()))
(t,) = I()
ar = [1, 11, 111, 1111]
for i in range(2, 10):
	ar += [j * i for j in ar[:4]]
for i in range(t):
	(n,) = I()
	an = 0
	i = 0
	while ar[i] != n:
		an += len(str(ar[i]))
		i += 1
	an += len(str(ar[i]))
	print(an)


def sum_n(x):
	ans = x * (x + 1) // 2
	return ans
t = int(input())
for i in range(t):
	n = int(input())
	dig = n % 10
	ans = 10 * (dig - 1) + sum_n(len(str(n)))
	print(ans)


T = int(input())
for t in range(T):
	x = input()
	d = x[0]
	l = len(x)
	ans = 10 * (int(d) - 1)
	ans += l * (l + 1) // 2
	print(ans)


for _ in range(int(input())):
	n = str(input())
	dig = int(n[0])
	diglen = len(n)
	count = 10 * (dig - 1) + diglen * (diglen + 1) // 2
	print(count)


for _ in range(int(input())):
	n = int(input())
	ans = False
	cnt = 0
	for i in range(1, 9 + 1):
		s = ''
		for j in range(4):
			s += str(i)
			cnt += j + 1
			if int(s) == n:
				ans = True
				break
		if ans:
			break
	print(cnt)


def answer(x):
	digit = int(x[0])
	return (digit - 1) * sum(range(5)) + sum(range(len(x) + 1))
t = int(input())
for _ in range(t):
	x = input()
	print(answer(x))


from math import *
from collections import *
from bisect import *
t = int(input())

def solve():
	x = input()
	n = int(x[0])
	c = len(x)
	flag = False
	ans = 0
	for i in range(1, 10):
		for j in range(1, 5):
			ans += j
			if i == n and j == c:
				flag = True
				print(ans)
				break
		if flag:
			break
p = 1
while t:
	t -= 1
	ans = solve()
	p += 1


for _ in range(int(input())):
	x = int(input())
	count = 0
	count += int(10 * (x % 10 - 1))
	temp = 0
	a = [int(i) for i in str(x)]
	l = len(a)
	count += int(l * (l + 1) / 2)
	print(count)


import math
from collections import Counter
try:
	for _ in range(int(input())):
		n = input()
		for i in range(1, 10):
			if int(n[0]) == i:
				ans = 10 * (i - 1)
				break
		x = len(n)
		if x == 1:
			print(ans + x)
		elif x == 2:
			print(ans + 3)
		elif x == 3:
			print(ans + 6)
		else:
			print(ans + 10)
except EOFError as e:
	print(e)


x = int(input())
arr = []
for i in range(x):
	c = input()
	arr.append(c)
counter = 0
arr3 = []
arr2 = ['1', '11', '111', '1111', '2', '22', '222', '2222', '3', '33', '333', '3333', '4', '44', '444', '4444', '5', '55', '555', '5555', '6', '66', '666', '6666', '7', '77', '777', '7777', '8', '88', '888', '8888', '9', '99', '999', '9999']
for i in range(len(arr)):
	value = 0
	index = arr2.index(arr[i])
	for x in range(index + 1):
		l = len(arr2[x])
		value = value + l
	arr3.append(value)
for i in arr3:
	print(i)


t = int(input())
while t != 0:
	s = input()
	n = int(s)
	count = 10 * (n % 10 - 1)
	if len(s) == 1:
		count += 1
	elif len(s) == 2:
		count += 3
	elif len(s) == 3:
		count += 6
	elif len(s) == 4:
		count += 10
	print(count)
	t -= 1


def cnt(s, i):
	s -= 1
	c = s * 10
	a = 0
	while a != i:
		c += i - a
		a += 1
	return c
for _ in range(int(input())):
	s = input()
	print(cnt(int(s[0]), len(s)))


t = int(input())
for i in range(t):
	_input = input()
	first_digit = int(_input[0])
	l = len(_input)
	ans = (first_digit - 1) * 10
	for j in range(1, l + 1):
		ans += j
	print(ans)


t = int(input())
while t:
	a = int(input())
	ans = 0
	row = (a % 10 - 1) * 10
	ans += row
	digits = 0
	while a:
		digits += 1
		a //= 10
	ans += digits / 2 * (digits + 1)
	t -= 1
	print(int(ans))


l = [1, 3, 6, 10]
for _ in range(int(input())):
	i = input()
	ans = (int(i[0]) - 1) * 10 + l[len(i) - 1]
	print(ans)


def boring_apartments():
	t_cases = int(input())
	count = 0
	extra = [0, 1, 3, 6, 10]
	for i in range(t_cases):
		apartment = input()
		count = (int(apartment[0]) - 1) * 10 + extra[len(apartment)]
		print(count)
boring_apartments()


import math

def solve():
	s = input()
	ans = 10 * (int(s[0]) - 1)
	if len(s) == 1:
		ans += 1
	elif len(s) == 2:
		ans += 3
	elif len(s) == 3:
		ans += 6
	else:
		ans += 10
	print(ans)
for z in range(int(input())):
	solve()


for i in range(int(input())):
	a = input()
	b = [1, 3, 6, 10]
	print((int(a[0]) - 1) * 10 + b[len(a) - 1])


t = int(input())
for i in range(t):
	x = int(input())
	y = x
	count_x = 0
	sum1 = 0
	while x != 0:
		count_x += 1
		x = x // 10
	while 1 <= count_x:
		sum1 += count_x
		count_x = count_x - 1
	rem1 = y % 10
	mul = (rem1 - 1) * 10
	sum1 += mul
	print(sum1)


def add(j):
	r = 0
	for i in range(j + 1):
		r += i
	return r
t = int(input())
for t in range(t):
	s = input()
	x = int(s)
	d = int(s[0])
	pressed = 10 * (d - 1) + add(len(s))
	print(pressed)


def is_special(x):
	if len([y for y in x if y != x[0]]) > 0:
		return False
	return True

def solve():
	x = list(input().strip())
	if not is_special(x):
		return 9 * (1 + 2 + 3 + 4)
	xx = int(x[0])
	return (xx - 1) * (1 + 2 + 3 + 4) + sum(range(1, 1 + len(x)))
for _ in range(int(input().strip())):
	print(solve())


def check(l, n):
	cnt = 0
	for i in range(len(l)):
		if l[i] == n:
			cnt += len(str(l[i]))
			break
		cnt += len(str(l[i]))
	return cnt
t = int(input())
while t:
	t = t - 1
	n = int(input())
	l = []
	for i in range(1, 10):
		l.append(i * 1)
		l.append(i * 1 + i * 10)
		l.append(i * 1 + i * 10 + i * 100)
		l.append(i * 1 + i * 10 + i * 100 + i * 1000)
	print(check(l, n))


from pprint import pprint
import sys

def do():
	n = int(input())
	x = n % 10
	res = (x - 1) * 10
	if len(str(n)) == 1:
		res += 1
	if len(str(n)) == 2:
		res += 1 + 2
	if len(str(n)) == 3:
		res += 1 + 2 + 3
	if len(str(n)) == 4:
		res += 1 + 2 + 3 + 4
	print(res)
q = int(input())
for _ in range(q):
	do()


from sys import stdin
for _ in range(int(stdin.readline())):
	n = int(stdin.readline())
	first = n % 10
	ans = 0
	ans += (first - 1) * 10
	d = len(str(n))
	ans += d * (d + 1) // 2
	print(ans)


import sys
import os
import math
import copy
from math import gcd
from bisect import bisect
from io import BytesIO, IOBase
from math import sqrt, floor, factorial, gcd, log, ceil
from collections import deque, Counter, defaultdict
from itertools import permutations, combinations
from itertools import accumulate

def Int():
	return int(sys.stdin.readline())

def Mint():
	return map(int, sys.stdin.readline().split())

def Lstr():
	return list(sys.stdin.readline().strip())

def Str():
	return sys.stdin.readline().strip()

def Mstr():
	return map(str, sys.stdin.readline().strip().split())

def List():
	return list(map(int, sys.stdin.readline().split()))

def Hash():
	return dict()

def Mod():
	return 1000000007

def Ncr(n, r, p):
	return fact[n] * (ifact[r] * ifact[n - r] % p) % p

def Most_frequent(list):
	return max(set(list), key=list.count)

def Mat2x2(n):
	return [List() for _ in range(n)]

def Lcm(x, y):
	return x * y // gcd(x, y)

def dtob(n):
	return bin(n).replace('0b', '')

def btod(n):
	return int(n, 2)

def common(l1, l2):
	return set(l1).intersection(l2)

def solution():
	for _ in range(Int()):
		n = Int()
		c = 0
		while n != 0:
			if n // 10 == 0:
				v = n
			n = n // 10
			c += 1
		f = (v - 1) * 10
		ans = 0
		if c == 1:
			ans = 1
		elif c == 2:
			ans = 3
		elif c == 3:
			ans = 6
		elif c == 4:
			ans = 10
		f += ans
		print(f)
solution()


t = int(input())
for i in range(t):
	n = int(input())
	k = str(n)
	l = list(k)
	p = int(l[0])
	s = 10 * (p - 1)
	if len(k) == 4:
		print(s + 10)
	if len(k) == 3:
		print(s + 6)
	if len(k) == 2:
		print(s + 3)
	if len(k) == 1:
		print(s + 1)


t = int(input())
while t:
	n = int(input())
	a = n % 10
	b = (a - 1) * 10
	l = len(str(n))
	result = b + l * (l + 1) // 2
	print(result)
	t -= 1


for i in range(int(input())):
	n = list(input())
	r = int(n[0]) - 1
	q = len(n)
	print(int(r * 10 + q * (q + 1) / 2))


t = int(input())
for i in range(t):
	n = int(input())
	s = (n % 10 - 1) * 10
	ns = str(n)
	length = len(ns)
	s += (1 + length) * length // 2
	print(s)


import math
test = int(input())
for t in range(test):
	tt = 0
	pp = 0
	cc = ''
	ss = ''
	dd = 1
	cnttt = 0
	x = int(input())
	a = x
	cnt = 0
	while a != 0:
		a = a // 10
		cnt += 1
	a = x % 10
	ans = (a - 1) * 10 + cnt * (cnt + 1) // 2
	print(ans)


MOD = 1000000007
from collections import defaultdict as dd, Counter, deque

def si():
	return input()

def ii():
	return int(input())

def li():
	return list(map(int, input().split()))

def mi():
	return map(int, input().split())

def out(v):
	print(v)

def spout():
	print(v, end=' ')

def d2b(n):
	return bin(n).replace('0b', '')

def twod(n, m, num):
	return [[num for x in range(m)] for y in range(n)]

def vow():
	return ['a', 'e', 'i', 'o', 'u']

def let():
	return [chr(i) for i in range(97, 123)]

def gcd(x, y):
	while y:
		(x, y) = (y, x % y)
	return x

def ispow2(x):
	return x and (not x & x - 1)

def prime_factors(n):
	i = 2
	factors = []
	while i * i <= n:
		if n % i:
			i += 1
		else:
			n //= i
			factors.append(i)
	if n > 1:
		factors.append(n)
	return list(factors)
t = ii()
while t:
	t -= 1
	n = ii()
	dig = 0
	m = n
	while m:
		m //= 10
		dig += 1
	m = n % 10
	print((m - 1) * 10 + dig * (dig + 1) // 2)


t = int(input())
d = 0
for i in range(t):
	d = 0
	x = int(input())
	for j in range(len(str(x)) + 1):
		d += j
	ans = 10 * (int(str(x)[0]) - 1) + d
	print(ans)


tests = int(input())
for _ in range(tests):
	n = int(input())
	k = str(n)
	ans = 0
	ans += 10 * (int(k[-1]) - 1)
	if len(k) == 1:
		ans += 1
	elif len(k) == 2:
		ans += 1 + 2
	elif len(k) == 3:
		ans += 1 + 2 + 3
	else:
		ans += 10
	print(ans)


t = int(input())
for _ in range(t):
	x = input().strip()
	cur = (int(x[0]) - 1) * 10
	if len(x) == 1:
		cur += 1
	elif len(x) == 2:
		cur += 3
	elif len(x) == 3:
		cur += 6
	else:
		cur += 10
	print(cur)


for _ in range(int(input())):
	x = input()
	n = int(x) % 10
	ct = x.count(str(n))
	cnt = (n - 1) * 10 + ct * (ct + 1) // 2
	print(cnt)


for a0 in range(int(input())):
	n = int(input())
	d = 0
	x = n % 10
	while n != 0:
		n = n // 10
		d += 1
	print(10 * (x - 1) + d * (d + 1) // 2)


for i in range(int(input())):
	n = int(input())
	s = str(n)
	count = 0
	if int(s[0]) > 1:
		count += (int(s[0]) - 1) * 10
	if len(s) == 1:
		count += 1
	elif len(s) == 2:
		count += 3
	elif len(s) == 3:
		count += 6
	else:
		count += 10
	print(count)


import sys
input = sys.stdin.readline
(inp, ip) = (lambda : int(input()), lambda : [int(w) for w in input().split()])
for _ in range(inp()):
	n = inp()
	ans = 0
	for i in range(1, 10):
		t = i
		j = 1
		while t != n and t <= 10000:
			t *= 10
			t += i
			j += 1
		ans += j * (j - 1) // 2
		if t == n:
			ans += len(str(n))
			break
	print(ans)


for _ in range(int(input())):
	s = input()
	k = len(s)
	a = k * (k + 1) // 2
	p = int(s[0])
	if p > 1:
		a += (p - 1) * 10
	print(a)


try:
	for i in range(int(input())):
		num = int(input())
		num_str = str(num)
		first = int(num_str[0])
		first -= 1
		first *= 10
		lenn = len(num_str)
		count = 0
		for i in range(1, lenn + 1):
			count += i
		print(first + count)
except:
	pass


a = []
k = 0
a.append(k)
for i in range(1, 10):
	k += 10
	a.append(k)
n = int(input())
while n > 0:
	summ = 0
	s = input()
	x = int(s[0])
	le = len(s)
	summ += a[x - 1] + (1 + le) * le // 2
	print(summ)
	n -= 1


t = int(input())
for _ in range(t):
	x = int(input())
	flag = True
	ans = 0
	for i in range(1, 10):
		if flag:
			s = 0
			for j in range(4):
				s *= 10
				s += i
				ans += j + 1
				if s == x:
					flag = False
					break
		else:
			break
	print(ans)


t = int(input())
for i in range(t):
	x = input()
	x1 = x[0]
	ans = 0
	xlen = len(x)
	for j in range(1, 10):
		if int(x1) > j:
			ans += 10
		else:
			if xlen == 1:
				ans += 1
			elif xlen == 2:
				ans += 3
			elif xlen == 3:
				ans += 6
			else:
				ans += 10
			break
	print(ans)


import math
t = int(input())
for i in range(t):
	n = input()
	print((int(n[0]) - 1) * 10 + len(n) * (len(n) + 1) // 2)


t = int(input())
for i in range(t):
	n = input()
	k = 1
	x = '1'
	k1 = 1
	while x != n:
		if len(x) != 4:
			x += str(k1)
		else:
			k1 += 1
			x = str(k1)
		k += len(x)
	print(k)


def func():
	n = input()
	l = len(n)
	setN = set(n)
	for i in setN:
		a = int(i)
	ans = 10 * (a - 1) + l * (l + 1) // 2
	print(ans)

def main():
	for i in range(int(input())):
		func()
main()


ans = []
for a in range(1, 9 + 1):
	tmp = 0
	for b in range(1, 4 + 1):
		tmp = tmp * 10 + a
		ans.append(tmp)
t = int(input())
while t:
	t = t - 1
	x = int(input())
	now = 0
	tmp = 1
	for a in ans:
		now += tmp
		tmp += 1
		if tmp > 4:
			tmp = 1
		if a == x:
			break
	print(now)


reqs = int(input())
arr = [1]
res_arr = []
x = 1
a = str(x)
counter = 0
while int(a) < 1000:
	a = str(a) + str(x)
	arr.append(int(a))
while x < 10:
	for elem in arr:
		elem *= x
		res_arr.append(elem)
	x += 1
del arr
for i in range(reqs):
	number_of_flat = int(input())
	index = res_arr.index(number_of_flat)
	for k in range(index + 1):
		counter += len(str(res_arr[k]))
	print(counter)
	counter = 0


t = int(input())
while t:
	t -= 1
	n = input()
	k = len(n)
	print(int(10 * (int(n[0]) - 1) + k * (k + 1) / 2))


t = int(input())
for i in range(t):
	str = input()
	d = int(str[0])
	r = int(10 * (d - 1) + len(str) * (len(str) + 1) / 2)
	print(r)


import sys
input = sys.stdin.readline
T = int(input())
A = []
B = []
for i in range(1, 10):
	for j in range(1, 5):
		A.append(int(str(i) * j))
		B.append(j)
for i in range(1, len(B)):
	B[i] = B[i] + B[i - 1]
for _ in range(T):
	n = int(input())
	v = A.index(n)
	print(B[v])


def digits(n):
	c = 0
	while n > 0:
		n = n // 10
		c += 1
	return c
t = int(input())
l = [1, 11, 111, 1111, 2, 22, 222, 2222, 3, 33, 333, 3333, 4, 44, 444, 4444, 5, 55, 555, 5555, 6, 66, 666, 6666, 7, 77, 777, 7777, 8, 88, 888, 8888, 9, 99, 999, 9999]
while t > 0:
	t -= 1
	x = int(input())
	s = 0
	for i in range(36):
		s += digits(l[i])
		if l[i] == x:
			break
	print(s)


while True:
	try:
		n = int(input())
		for i in range(n):
			a = input()
			shu = int(a[0])
			len1 = len(a)
			ans = 0
			aa = 1
			for i in range(len1):
				ans += aa
				aa += 1
			ans += (shu - 1) * 10
			print(ans)
	except:
		break


def res(n):
	n = str(n)
	l = len(n)
	if l == 4:
		return int(n[0]) * (1 + 2 + 3 + 4)
	if l == 3:
		return int(n[0]) * (1 + 2 + 3) + (int(n[0]) - 1) * 4
	if l == 2:
		return int(n[0]) * (1 + 2) + (int(n[0]) - 1) * (3 + 4)
	if l == 1:
		return int(n[0]) * 1 + (int(n[0]) - 1) * (2 + 3 + 4)
t = int(input())
for i in range(t):
	j = input()
	print(res(j))


t = int(input())
for _ in range(t):
	n = int(input())
	n = str(n)
	s = len(n)
	ans = 10 * (int(n[0]) - 1) + s * (s + 1) // 2
	print(ans)


for _ in range(int(input())):
	x = int(input())
	print(10 * (x % 10) - 10 + len(str(x)) * (len(str(x)) + 1) // 2)


R = lambda : map(int, input().split())
for _ in range(int(input())):
	n = input()
	ans = 0
	for i in range(int(n[0]) - 1):
		ans += 10
	l = len(n)
	if l == 1:
		ans += 1
	elif l == 2:
		ans += 3
	elif l == 3:
		ans += 6
	elif l == 4:
		ans += 10
	print(ans)


t = int(input())
for _ in range(t):
	dp = [1, 3, 6, 10]
	s = input()
	res = (int(s[0]) - 1) * 10
	res += dp[len(s) - 1]
	print(res)


import sys, os
t = sys.stdin.readline().strip()
for _ in range(0, int(t)):
	x = sys.stdin.readline().strip()
	n = len(x)
	s = int(x[0])
	ans = 10 * (s - 1)
	if n == 1:
		ans += 1
	elif n == 2:
		ans += 3
	elif n == 3:
		ans += 6
	elif n == 4:
		ans += 10
	print(ans)


def solve():
	x = int(input())
	ans = 0
	ok = 0
	for i in range(1, 10):
		n = 0
		for j in range(4):
			n = n * 10 + i
			ans += j + 1
			if n == x:
				ok = 1
				break
		if ok:
			break
	print(ans)

def main():
	t = 1
	t = int(input())
	for _ in range(t):
		solve()
main()


import os
import sys
from io import BytesIO, IOBase
import math
from itertools import permutations
from decimal import *
getcontext().prec = 25
MOD = pow(10, 9) + 7
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
input = lambda : sys.stdin.readline().rstrip('\r\n')
for _ in range(int(input())):
	n = int(input())
	a = n % 10
	x = len(str(n))
	ans = 10 * (a - 1) + x * (x + 1) // 2
	print(ans)


r = []
for i in range(1, 9 + 1):
	t = ''
	for j in range(1, 4 + 1):
		t += str(i)
		r.append(t)
rl = [len(each) for each in r]
count = int(input())
for _ in range(count):
	num = input()
	print(sum(rl[:r.index(num) + 1]))


def main():
	a = []
	for i in range(1, 10):
		for j in range(1, 5):
			a.append((int(str(i) * j), j))
	t = int(input())
	for i in range(t):
		x = int(input())
		ans = 0
		i = 0
		while a[i][0] != x and i < len(a):
			ans += a[i][1]
			i += 1
		ans += a[i][1]
		print(ans)
main()


for _ in range(int(input())):
	k = input()
	count = 0
	count += 10 * (int(k[0]) - 1)
	for i in range(1, len(k) + 1):
		count += i
	print(count)


n = int(input())
l = []
for i in range(n):
	l.append(input())
for i in range(n):
	s = int(l[i][0])
	y = len(l[i])
	if y == 1:
		h = s * 1 + (s - 1) * 2 + (s - 1) * 3 + (s - 1) * 4
	if y == 2:
		h = s * 1 + s * 2 + (s - 1) * 3 + (s - 1) * 4
	if y == 3:
		h = s * 1 + s * 2 + s * 3 + (s - 1) * 4
	if y == 4:
		h = s * 1 + s * 2 + s * 3 + s * 4
	print(h)


t = int(input())
for i in range(t):
	n = input()
	z = len(n)
	k = int(n) % 10
	print(round((k - 1) * 10 + z * (z + 1) / 2))


import sys
read = sys.stdin.read

def main():
	t = int(input())
	m = tuple(read().split())
	for me in m:
		mes = int(me[0])
		melen = len(me)
		ans = (mes - 1) * 10
		if melen == 1:
			ans += 1
		elif melen == 2:
			ans += 3
		elif melen == 3:
			ans += 6
		else:
			ans += 10
		print(ans)
main()


n = int(input())
lst = [0, 1, 3, 6, 10]
for _ in range(n):
	s = input()
	ans = 0
	leng = len(s)
	dig = int(s[0])
	ans += dig * 10 - 10
	ans += lst[leng]
	print(ans)


t = int(input())
out = {1: 1, 2: 3, 3: 6, 4: 10}
for _ in range(t):
	x = input()
	(xlen, xval) = (len(x), int(x))
	if xlen == 1:
		print(out[xlen] + 10 * (xval - 1))
	elif xlen == 2:
		print(out[xlen] + (xval // 11 - 1) * 10)
	elif xlen == 3:
		print(out[xlen] + (xval // 111 - 1) * 10)
	else:
		print(out[xlen] + (xval // 1111 - 1) * 10)


for _ in range(int(input())):
	x = input()
	l = len(x)
	a = x[0]
	a = int(a)
	a -= 1
	sum = a * 10
	cnt = l * (l + 1) // 2
	sum += cnt
	print(sum)


def solve(x):
	ans = 10 * (x % 10 - 1)
	num = len(str(x))
	ans += (1 + num) * num // 2
	return ans
t = int(input())
for _ in range(t):
	x = int(input())
	print(solve(x))


t = int(input())
for _ in range(t):
	s = input()
	s = str(s)
	l = len(s)
	x = int(s[0])
	z = 0
	if l == 1:
		z = 1
	elif l == 2:
		z = 3
	elif l == 3:
		z = 6
	else:
		z = 10
	ans = (x - 1) * 10 + z
	print(ans)


end = 10000
t = int(input())
while t:
	x = input()
	num = int(x)
	val = int(x[0])
	total = 10 * (val - 1)
	if 1 <= num <= 10:
		total += 1
	elif 10 < num <= 100:
		total += 3
	elif 100 < num <= 1000:
		total += 6
	elif 1000 < num <= 10000:
		total += 10
	print(total)
	t -= 1


arr = [1, 11, 111, 1111, 2, 22, 222, 2222, 3, 33, 333, 3333, 4, 44, 444, 4444, 5, 55, 555, 5555, 6, 66, 666, 6666, 7, 77, 777, 7777, 8, 88, 888, 8888, 9, 99, 999, 9999]
new = [1, 2, 3, 4, 1, 2, 3, 4, 1, 2, 3, 4, 1, 2, 3, 4, 1, 2, 3, 4, 1, 2, 3, 4, 1, 2, 3, 4, 1, 2, 3, 4, 1, 2, 3, 4]
t = int(input())
while t:
	n = int(input())
	idx = arr.index(n)
	s = 0
	for i in range(idx + 1):
		s += new[i]
	print(s)
	t -= 1


a = int(input())
for i in range(a):
	b = input()
	if b[0] == '1':
		if len(b) == 1:
			print(1)
		if len(b) == 2:
			print(3)
		if len(b) == 3:
			print(6)
		if len(b) == 4:
			print(10)
	if b[0] == '2':
		if len(b) == 1:
			print(10 + 1)
		if len(b) == 2:
			print(10 + 3)
		if len(b) == 3:
			print(6 + 10)
		if len(b) == 4:
			print(10 + 10)
	if b[0] == '3':
		if len(b) == 1:
			print(20 + 1)
		if len(b) == 2:
			print(20 + 3)
		if len(b) == 3:
			print(6 + 20)
		if len(b) == 4:
			print(10 + 20)
	if b[0] == '4':
		if len(b) == 1:
			print(30 + 1)
		if len(b) == 2:
			print(30 + 3)
		if len(b) == 3:
			print(6 + 30)
		if len(b) == 4:
			print(10 + 30)
	if b[0] == '5':
		if len(b) == 1:
			print(40 + 1)
		if len(b) == 2:
			print(40 + 3)
		if len(b) == 3:
			print(6 + 40)
		if len(b) == 4:
			print(10 + 40)
	if b[0] == '6':
		if len(b) == 1:
			print(50 + 1)
		if len(b) == 2:
			print(50 + 3)
		if len(b) == 3:
			print(6 + 50)
		if len(b) == 4:
			print(10 + 50)
	if b[0] == '7':
		if len(b) == 1:
			print(60 + 1)
		if len(b) == 2:
			print(60 + 3)
		if len(b) == 3:
			print(6 + 60)
		if len(b) == 4:
			print(10 + 60)
	if b[0] == '8':
		if len(b) == 1:
			print(70 + 1)
		if len(b) == 2:
			print(70 + 3)
		if len(b) == 3:
			print(6 + 70)
		if len(b) == 4:
			print(10 + 70)
	if b[0] == '9':
		if len(b) == 1:
			print(80 + 1)
		if len(b) == 2:
			print(80 + 3)
		if len(b) == 3:
			print(6 + 80)
		if len(b) == 4:
			print(10 + 80)


from __future__ import division, print_function
import os
import sys
from io import BytesIO, IOBase
if sys.version_info[0] < 3:
	from __builtin__ import xrange as range
	from future_builtins import ascii, filter, hex, map, oct, zip

def main():
	t = int(input())
	for _ in range(t):
		x = input()
		l = len(x)
		print(10 * (int(x[0]) - 1) + sum(range(l + 1)))
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')

def print(*args, **kwargs):
	(sep, file) = (kwargs.pop('sep', ' '), kwargs.pop('file', sys.stdout))
	at_start = True
	for x in args:
		if not at_start:
			file.write(sep)
		file.write(str(x))
		at_start = False
	file.write(kwargs.pop('end', '\n'))
	if kwargs.pop('flush', False):
		file.flush()
if sys.version_info[0] < 3:
	(sys.stdin, sys.stdout) = (FastIO(sys.stdin), FastIO(sys.stdout))
else:
	(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
input = lambda : sys.stdin.readline().rstrip('\r\n')
main()


A = []
for i in range(1, 10):
	for j in range(1, 5):
		A.append(str(i) * j)

def solve(n):
	ans = 0
	for boring in A:
		ans += len(boring)
		if int(boring) == n:
			return ans
for t in range(int(input())):
	n = int(input())
	print(solve(n))


for u in range(int(input())):
	n = int(input())
	ans = 0
	ans += 10 * (n % 10 - 1)
	s = len(str(n))
	ans += s * (s + 1) // 2
	print(ans)


from math import *
import sys
from sys import stdin
from sys import stdout
for __ in range(int(input())):
	s = input()
	ans = 0
	c = 1
	for i in range(1, 10):
		for j in range(1, 5):
			ans += j
			if s == str(i) * j:
				c = 0
				break
		if c == 0:
			break
	print(ans)


n = int(input())
for i in range(n):
	x = input()
	k = len(x)
	sumi = 10 * (int(x) % 10 - 1)
	for g in range(1, k + 1):
		sumi += g
	print(sumi)


lst = [[1, 11, 111, 1111], [2, 22, 222, 2222], [3, 33, 333, 3333], [4, 44, 444, 4444], [5, 55, 555, 5555], [6, 66, 666, 6666], [7, 77, 777, 7777], [8, 88, 888, 8888], [9, 99, 999, 9999]]
for iii in range(int(input())):
	x = int(input())
	ans = 0
	flag = True
	for i in range(9):
		for j in range(4):
			if lst[i][j] != x:
				ans += len(str(lst[i][j]))
			else:
				flag = False
				break
		if not flag:
			break
	print(ans + len(str(x)))


for i in range(int(input())):
	n = list(map(int, input()))
	if len(n) == 1:
		c = 1
	elif len(n) == 2:
		c = 3
	elif len(n) == 3:
		c = 6
	elif len(n) == 4:
		c = 10
	print(10 * (n[0] - 1) + c)


test_cases = int(input())
while test_cases != 0:
	test_cases = test_cases - 1
	n = input()
	buttons = (int(n[0]) - 1) * 10 + sum([1, 2, 3, 4][:len(n)])
	print(buttons)


for _ in range(int(input())):
	n = input()
	if n == '0':
		print('0')
	else:
		print((int(n[0]) - 1) * 10 + sum(range(1, len(n) + 1)))


for _ in ' ' * int(input()):
	s = input()
	k = len(s)
	ans = 0
	while k > 0:
		ans += k
		k -= 1
	ans += (int(s[0]) - 1) * 10
	print(ans)


def farr(s):
	all_freq = {}
	for i in s:
		if i in all_freq:
			all_freq[i] += 1
		else:
			all_freq[i] = 1
	return all_freq

def nextInt():
	return int(input())

def intArr():
	arr = input().split(' ')
	return [int(x) for x in arr]
t = nextInt()
ans = []
for tt in range(t):
	x = nextInt()
	c = (int(str(x)[0]) - 1) * 10
	if len(str(x)) == 1:
		c += 1
	elif len(str(x)) == 2:
		c += 3
	elif len(str(x)) == 3:
		c += 6
	else:
		c += 10
	ans.append(c)
for x in ans:
	print(x)


def main():
	base_count = 13
	t = int(input())
	for __ in range(t):
		s = input()
		ans = (int(s[0]) - 1) * 10
		n = len(s)
		ans += n * (n + 1) // 2
		print(ans)
main()


t = int(input())
for _ in range(t):
	x = input()
	sum = 0
	a = int(x[0])
	sum = 10 * (a - 1)
	x = len(x)
	sum += x * (x + 1) / 2
	print(int(sum))


t = int(input())
for _ in range(t):
	n = int(input())
	x = n % 10
	c = (x - 1) * 10
	if len(str(n)) == 1:
		print(c + 1)
	elif len(str(n)) == 2:
		print(c + 3)
	elif len(str(n)) == 3:
		print(c + 6)
	else:
		print(c + 10)


n = int(input())
for _ in range(n):
	apartment = input()
	a = (int(apartment[0:1]) - 1) * 10
	hold = 1
	for i in range(len(apartment)):
		a += hold
		hold += 1
	print(a)


for i in range(int(input())):
	x = list(map(int, input()))
	if sum(x) == x[0] * len(x):
		if len(x) == 4:
			print(10 * (x[0] - 1) + 10)
		elif len(x) == 3:
			print(10 * (x[0] - 1) + 6)
		elif len(x) == 2:
			print(10 * (x[0] - 1) + 3)
		elif len(x) == 1:
			if x[0] > 1:
				print(10 * (x[0] - 1) + 1)
			else:
				print('1')
	else:
		print('0')


tc = int(input())
for _ in range(tc):
	x = input()
	n = len(x)
	y = int(x) % 10
	s = 0
	for i in range(n):
		s += i + 1
	res = (y - 1) * 10 + s
	print(res)


def solve(n):
	index = a.index(n) + 1
	ans = index // 4 * 10
	m = [0, 1, 3, 6]
	ans += m[index % 4]
	return ans
noOfTestCases = int(input())
a = [1, 11, 111, 1111, 2, 22, 222, 2222, 3, 33, 333, 3333, 4, 44, 444, 4444, 5, 55, 555, 5555, 6, 66, 666, 6666, 7, 77, 777, 7777, 8, 88, 888, 8888, 9, 99, 999, 9999]
for i in range(noOfTestCases):
	n = int(input())
	ans = solve(n)
	print(ans)


T = int(input())
boring_Apart = []
for i in range(1, 10):
	boring_Apart.extend([i, i * 10 + i, i * 100 + i * 10 + i * 1, i * 1000 + i * 100 + i * 10 + i * 1])
for i in range(T):
	key = input()
	l = int(key[0])
	index = (l - 1) * 4 + len(key) - 1
	sum = 0
	for i in range(index + 1):
		sum = sum + len(str(boring_Apart[i]))
	print(sum)


for _ in range(int(input())):
	n = int(input())
	i = n % 10 - 1
	k = 0
	while n != 0:
		k += 1
		n = n // 10
	k = k * (k + 1) // 2
	print(i * 10 + k)


x = int(input())
nums = [int(input()) for _ in range(x)]
for i in nums:
	number = i
	add = (number % 10 - 1) * 10
	length = len(str(number))
	add += length * (length + 1) // 2
	print(add)


import sys
sys.setrecursionlimit(10 ** 5)
int1 = lambda x: int(x) - 1
p2D = lambda x: print(*x, sep='\n')

def II():
	return int(sys.stdin.buffer.readline())

def MI():
	return map(int, sys.stdin.buffer.readline().split())

def LI():
	return list(map(int, sys.stdin.buffer.readline().split()))

def LLI(rows_number):
	return [LI() for _ in range(rows_number)]

def BI():
	return sys.stdin.buffer.readline().rstrip()

def SI():
	return sys.stdin.buffer.readline().rstrip().decode()
for _ in range(II()):
	t = SI()
	a = int(t[0]) - 1
	b = len(t)
	ans = 10 * a + b * (b + 1) // 2
	print(ans)


t = int(input())
for _ in range(t):
	n = input().strip()
	n1 = int(n[0]) - 1
	print(n1 * 10 + sum([i + 1 for i in range(len(n))]))


import sys
from collections import defaultdict
input = sys.stdin.readline
for _ in range(int(input())):
	n = int(input())
	lis = [1, 11, 111, 1111]
	for j in range(2, 10):
		for i in range(4):
			lis.append(j * lis[i])
	c = 0
	for i in lis:
		c += len(str(i))
		if i == n:
			break
	print(c)


for i in range(int(input())):
	n = int(input())
	c = 0
	flag = 0
	for j in range(1, 10):
		t = 0
		for k in range(1, 5):
			t = t * 10 + j
			c += len(str(t))
			if t == n:
				print(c)
				flag += 1
				break
		if flag == 1:
			break


n = int(input())
while n > 0:
	s = input()
	k = len(s)
	x = int(s[0])
	print(int(k * (k + 1) / 2 + 10 * (x - 1)))
	n -= 1


T = int(input())
while T != 0:
	n = int(input())
	k = n % 10
	s = (k - 1) * 10
	lent = len(str(n))
	su = sum(list(range(lent + 1)))
	print(s + su)
	T -= 1


for _ in range(int(input())):
	n = input()
	ans = (int(n[0]) - 1) * 10
	l = len(n)
	if l == 1:
		ans += 1
	elif l == 2:
		ans += 3
	elif l == 3:
		ans += 6
	else:
		ans += 10
	print(ans)


import math
t = int(input())
for q in range(t):
	n = int(input())
	a = [1, 2, 3, 4]
	l = [1, 2, 3, 4, 5, 6, 7, 8, 9]
	f = n % 10
	le = int(math.log(n, 10)) + 1
	ans = 0
	c = 0
	ans = 10 * (f - 1)
	for i in range(le):
		ans = ans + a[c]
		c = (c + 1) % 4
	print(ans)


for _ in range(int(input())):
	x = input()
	n = len(x)
	count = n * (n + 1) // 2
	count += int(x[0]) * 10 - 10
	print(count)


n = int(input())
while n > 0:
	s = input()
	l = len(s)
	a = int(s[0])
	output = 0
	if l == 1:
		output = (a - 1) * 10 + 1
	elif l == 2:
		output = (a - 1) * 10 + 3
	elif l == 3:
		output = (a - 1) * 10 + 6
	else:
		output = (a - 1) * 10 + 10
	print(output)
	n = n - 1


for _ in range(int(input())):
	n = int(input())
	s = str(n)
	r = (n % 10 - 1) * 10
	r += (len(s) + 1) * len(s) // 2
	print(r)


n = input()
for _ in range(int(n)):
	k = input()
	lk = len(k)
	print(int((int(k[0]) - 1) * 10 + lk * (lk + 1) / 2))


def countDigit(n):
	count = 0
	while n != 0:
		n //= 10
		count += 1
	return count
for _ in range(int(input())):
	x = int(input())
	num = x % 10
	count = countDigit(x)
	total = (num - 1) * 10
	tmp = count * (count + 1)
	tmp //= 2
	total += tmp
	print(total)


def countDigit(n):
	count = 0
	while n != 0:
		n //= 10
		count += 1
	return count
t = int(input())
for i in range(t):
	n = int(input())
	count = countDigit(n)
	LD = n % 10
	total = (LD - 1) * 10
	if count == 1:
		total += 1
	elif count == 2:
		total += 3
	elif count == 3:
		total += 6
	elif count == 4:
		total += 10
	print(total)


import sys
import math
n = int(input())
for i in range(n):
	x = input()
	fD = int(x[0])
	l = len(x)
	if l == 1:
		d = 1
	elif l == 2:
		d = 3
	elif l == 3:
		d = 6
	else:
		d = 10
	digits = (fD - 1) * 10 + d
	print(digits)


t = int(input())
for _ in range(t):
	x = list(map(int, input()))
	y = int(''.join((str(d) for d in x)))
	result = []
	if y == 1111:
		print(10)
	elif y == 2222:
		print('20')
	elif y == 3333:
		print('30')
	elif y == 4444:
		print('40')
	elif y == 5555:
		print('50')
	elif y == 6666:
		print('60')
	elif y == 7777:
		print('70')
	elif y == 8888:
		print('80')
	elif y == 9999:
		print('90')
	elif y == 10000:
		print('91')
	elif len(x) == 1:
		for n in range(1, 11):
			if x[0] == n and n != 1:
				result.append(n - 1)
				result.append(1)
			if x[0] == 1 and n == 1:
				result.append(1)
	elif y == 11:
		print(3)
	elif y == 111:
		print(6)
	elif y == 1111:
		print(10)
	else:
		for n in range(1, 11):
			if x[0] == 1:
				result.append(1)
			elif x[0] == n:
				result.append(n - 1)
				if len(x) == 2:
					result.append(3)
				elif len(x) == 3:
					result.append(6)
				elif len(x) == 4:
					result.append(9)
	final = ''.join((str(i) for i in result))
	if final != '':
		print(final)


for i in range(int(input())):
	n = int(input())
	if n <= 9:
		if n == 1:
			print(1)
		else:
			print(1 + 10 * (n - 1))
		continue
	if n == 11 or n == 111 or n == 1111:
		s = len(str(n))
		print(s * (s + 1) // 2)
		continue
	if n == 22 or n == 222 or n == 2222:
		s = len(str(n))
		print(10 + s * (s + 1) // 2)
		continue
	if n == 33 or n == 333 or n == 3333:
		s = len(str(n))
		print(20 + s * (s + 1) // 2)
		continue
	if n == 44 or n == 444 or n == 4444:
		s = len(str(n))
		print(30 + s * (s + 1) // 2)
		continue
	if n == 55 or n == 555 or n == 5555:
		s = len(str(n))
		print(40 + s * (s + 1) // 2)
		continue
	if n == 66 or n == 666 or n == 6666:
		s = len(str(n))
		print(50 + s * (s + 1) // 2)
		continue
	if n == 77 or n == 777 or n == 7777:
		s = len(str(n))
		print(60 + s * (s + 1) // 2)
		continue
	if n == 88 or n == 888 or n == 8888:
		s = len(str(n))
		print(70 + s * (s + 1) // 2)
		continue
	if n == 99 or n == 999 or n == 9999:
		s = len(str(n))
		print(80 + s * (s + 1) // 2)
		continue


b = [[int(str(a) * i) for i in range(1, 5)] for a in range(1, 10)]
for _ in range(int(input())):
	e = int(input())
	c = 0
	for a in b:
		o = False
		for (t, i) in enumerate(a):
			c += t + 1
			if i == e:
				o = True
				break
		if o:
			break
	print(c)


import sys, bisect, string, math, time, functools, random, fractions
from heapq import heappush, heappop, heapify
from collections import deque, defaultdict, Counter
from itertools import permutations, combinations, groupby
rep = range
R = range

def Golf():
	(n, *t) = map(int, open(0).read().split())

def I():
	return int(input())

def S_():
	return input()

def IS():
	return input().split()

def LS():
	return [i for i in input().split()]

def MI():
	return map(int, input().split())

def LI():
	return [int(i) for i in input().split()]

def LI_():
	return [int(i) - 1 for i in input().split()]

def NI(n):
	return [int(input()) for i in range(n)]

def NI_(n):
	return [int(input()) - 1 for i in range(n)]

def NLI(n):
	return [[int(i) for i in input().split()] for i in range(n)]

def NLI_(n):
	return [[int(i) - 1 for i in input().split()] for i in range(n)]

def StoLI():
	return [ord(i) - 97 for i in input()]

def ItoS(n):
	return chr(n + 97)

def LtoS(ls):
	return ''.join([chr(i + 97) for i in ls])

def RA():
	return map(int, open(0).read().split())

def RLI(n=8, a=1, b=10):
	return [random.randint(a, b) for i in range(n)]

def RI(a=1, b=10):
	return random.randint(a, b)

def INP():
	N = 10
	A = 10
	n = random.randint(1, N)
	a = [random.randint(1, A) for i in range(n)]
	return (n, a)

def Rtest(T):
	(case, err) = (0, 0)
	for i in range(T):
		inp = INP()
		a1 = naive(*inp)
		a2 = solve(*inp)
		if a1 != a2:
			print((a1, a2), inp)
			err += 1
		case += 1
	print('Tested', case, 'case with', err, 'errors')

def GI(V, E, ls=None, Directed=False, index=1):
	org_inp = []
	g = [[] for i in range(V)]
	FromStdin = True if ls == None else False
	for i in range(E):
		if FromStdin:
			inp = LI()
			org_inp.append(inp)
		else:
			inp = ls[i]
		if len(inp) == 2:
			(a, b) = inp
			c = 1
		else:
			(a, b, c) = inp
		if index == 1:
			a -= 1
			b -= 1
		aa = (a, c)
		bb = (b, c)
		g[a].append(bb)
		if not Directed:
			g[b].append(aa)
	return (g, org_inp)

def GGI(h, w, search=None, replacement_of_found='.', mp_def={'#': 1, '.': 0}, boundary=1):
	mp = [boundary] * (w + 2)
	found = {}
	for i in R(h):
		s = input()
		for char in search:
			if char in s:
				found[char] = (i + 1) * (w + 2) + s.index(char) + 1
				mp_def[char] = mp_def[replacement_of_found]
		mp += [boundary] + [mp_def[j] for j in s] + [boundary]
	mp += [boundary] * (w + 2)
	return (h + 2, w + 2, mp, found)

def TI(n):
	return GI(n, n - 1)

def accum(ls):
	rt = [0]
	for i in ls:
		rt += [rt[-1] + i]
	return rt

def bit_combination(n, base=2):
	rt = []
	for tb in R(base ** n):
		s = [tb // base ** bt % base for bt in R(n)]
		rt += [s]
	return rt

def gcd(x, y):
	if y == 0:
		return x
	if x % y == 0:
		return y
	while x % y != 0:
		(x, y) = (y, x % y)
	return y

def YN(x):
	print(['NO', 'YES'][x])

def Yn(x):
	print(['No', 'Yes'][x])

def show(*inp, end='\n'):
	if show_flg:
		print(*inp, end=end)
mo = 10 ** 9 + 7
inf = float('inf')
FourNb = [(-1, 0), (1, 0), (0, 1), (0, -1)]
EightNb = [(-1, 0), (1, 0), (0, 1), (0, -1), (1, 1), (-1, -1), (1, -1), (-1, 1)]
compas = dict(zip('WENS', FourNb))
cursol = dict(zip('LRUD', FourNb))
l_alp = string.ascii_lowercase
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
input = lambda : sys.stdin.readline().rstrip()
show_flg = False
show_flg = True
ans = 0
for _ in range(I()):
	ans = 0
	s = input()
	n = int(s)
	x = int(s[0]) - 1
	d = len(s)
	ans = x * 10 + d * (d + 1) // 2
	print(ans)


tests = int(input())
for test in range(tests):
	s = input().strip()
	print((int(s[0]) - 1) * 10 + len(s) * (len(s) + 1) // 2)


def process():
	x = int(input())
	list_apt = [1, 11, 111, 1111]
	new_list = [1, 11, 111, 1111]
	target = 0
	count = 0
	number_digit = 0
	while target != x:
		target = new_list[count]
		count += 1
		number_digit += count
		if count % 4 == 0:
			count = 0
			for i in range(4):
				new_list[i] += list_apt[i]
	return number_digit

def resolve():
	testCase = int(input())
	for i in range(testCase):
		print(process())
resolve()


from sys import stdin, stdout
import math
import heapq
import collections
input = stdin.readline

def inputnum():
	return int(input())

def inputnums():
	return map(int, input().split())

def inputlist():
	return list(map(int, input().split()))

def inputstring():
	return [x for x in input()]

def inputstrings():
	return [x for x in input().split()]

def inputstringnum():
	return [ord(x) - ord('a') for x in input()]

def inputmatrixchar(rows):
	arr2d = [[j for j in input().strip()] for i in range(rows)]
	return arr2d

def inputmatrixint(rows):
	arr2d = []
	for _ in range(rows):
		arr2d.append([int(i) for i in input().split()])
	return arr2d
t = int(input())
for q in range(t):
	n = inputnum()
	N = n
	l = 0
	while n > 0:
		n //= 10
		l += 1
	print(10 * (N % 10 - 1) + l * (l + 1) // 2)


arr = []
i = 1
while i <= 9:
	xx = str(i)
	while len(xx) < 5:
		arr.append(xx)
		xx += str(i)
	i += 1
pre = [0] * len(arr)
pre[0] = len(arr[0])
for i in range(1, len(arr)):
	pre[i] = pre[i - 1] + len(arr[i])
t = int(input())
for i in range(t):
	n = int(input())
	print(pre[arr.index(str(n))])


import array
t = int(input())
ans = array.array('i', [0] * t)
for i in range(t):
	x = input()
	x1 = int(x[0])
	x2 = len(x)
	ans[i] = (x1 - 1) * 10 + x2 * (x2 + 1) // 2
for i in ans:
	print(i)


def testcase():
	x = int(input())
	d = x % 10
	l = len(str(x))
	ans = (d - 1) * 10 + l * (l + 1) // 2
	print(ans)
	return
t = int(input())
for _ in range(t):
	testcase()


t = int(input())
for _ in range(0, t):
	n = int(input())
	z = str(n)
	x = int(z[0])
	if x == 1:
		sum1 = 0
		if len(z) == 1:
			sum1 += 1
		elif len(z) == 2:
			sum1 += 3
		elif len(z) == 3:
			sum1 += 6
		elif len(z) == 4:
			sum1 += 10
		print(sum1)
	else:
		sum1 = 10
		x = x - 1
		sum1 = sum1 * x
		if len(z) == 1:
			sum1 += 1
		elif len(z) == 2:
			sum1 += 3
		elif len(z) == 3:
			sum1 += 6
		elif len(z) == 4:
			sum1 += 10
		print(sum1)


t = int(input())
while t:
	s = input()
	n = int(s)
	l = len(s)
	add = 0
	for i in range(l + 1):
		add += i
	ans = (int(s[0]) - 1) * 10 + add
	print(ans)
	t -= 1


for _ in range(int(input())):
	a = int(input())
	x = -1 if len(str(a)) < 3 else 0 if len(str(a)) == 3 else 2
	fri = (a % 10 - 1) * 10
	se = 2 * len(str(a)) + x
	print(fri + se)


t = int(input())
for _ in range(t):
	n = int(input())
	total = 0
	for i in range(1, 10):
		sum = 0
		for j in range(1, 5):
			sum = sum * 10 + i
			total += j
			if sum == n:
				print(total)
				break


from math import *
t = int(input())
for _ in range(t):
	n = input()
	k = 10 * (int(n[0]) - 1)
	if len(n) == 1:
		k += 1
	elif len(n) == 2:
		k += 3
	elif len(n) == 3:
		k += 6
	else:
		k += 10
	print(k)


import sys
import math
import itertools
import functools
import collections
import operator
import fileinput
import copy
import string
ORDA = 97

def ii():
	return int(input())

def mi():
	return map(int, input().split())

def li():
	return [int(i) for i in input().split()]

def lcm(a, b):
	return abs(a * b) // math.gcd(a, b)

def revn(n):
	return str(n)[::-1]

def dd():
	return collections.defaultdict(int)

def ddl():
	return collections.defaultdict(list)

def sieve(n):
	if n < 2:
		return list()
	prime = [True for _ in range(n + 1)]
	p = 3
	while p * p <= n:
		if prime[p]:
			for i in range(p * 2, n + 1, p):
				prime[i] = False
		p += 2
	r = [2]
	for p in range(3, n + 1, 2):
		if prime[p]:
			r.append(p)
	return r

def divs(n, start=2):
	r = []
	for i in range(start, int(math.sqrt(n) + 1)):
		if n % i == 0:
			if n / i == i:
				r.append(i)
			else:
				r.extend([i, n // i])
	return r

def divn(n, primes):
	divs_number = 1
	for i in primes:
		if n == 1:
			return divs_number
		t = 1
		while n % i == 0:
			t += 1
			n //= i
		divs_number *= t

def prime(n):
	if n == 2:
		return True
	if n % 2 == 0 or n <= 1:
		return False
	sqr = int(math.sqrt(n)) + 1
	for d in range(3, sqr, 2):
		if n % d == 0:
			return False
	return True

def convn(number, base):
	new_number = 0
	while number > 0:
		new_number += number % base
		number //= base
	return new_number

def cdiv(n, k):
	return n // k + (n % k != 0)

def ispal(s):
	for i in range(len(s) // 2 + 1):
		if s[i] != s[-i - 1]:
			return False
	return True
for _ in range(ii()):
	x = input()
	print((int(x[0]) - 1) * 10 + len(x) * (len(x) + 1) // 2)


t = int(input())
for i in range(t):
	a = int(input())
	val = 0
	b = a % 10
	if b > 1:
		val = 10 * (b - 1)
		if len(str(a)) == 1:
			print(val + 1)
		elif len(str(a)) == 2:
			print(val + 3)
		elif len(str(a)) == 3:
			print(val + 6)
		else:
			print(val + 10)
	elif len(str(a)) == 1:
		print(val + 1)
	elif len(str(a)) == 2:
		print(val + 3)
	elif len(str(a)) == 3:
		print(val + 6)
	else:
		print(val + 10)


n = int(input())
sumt = 0
l = [int(input()) for i in range(n)]
m = [1, 11, 111, 1111, 2, 22, 222, 2222, 3, 33, 333, 3333, 4, 44, 444, 4444, 5, 55, 555, 5555, 6, 66, 666, 6666, 7, 77, 777, 7777, 8, 88, 888, 8888, 9, 99, 999, 9999]
for i in l:
	for j in m:
		if i != j:
			sumt += len(str(j))
		else:
			print(sumt + len(str(i)))
			break
	sumt = 0


import sys

def solve():
	k = list(input())
	s = (int(k[0]) - 1) * 10
	if len(k) == 1:
		s += 1
	if len(k) == 2:
		s += 3
	if len(k) == 3:
		s += 6
	if len(k) == 4:
		s += 10
	print(s)
a = int(input())
for i in range(a):
	solve()


t = int(input())
while t:
	s = input()
	n = len(s)
	k = '1' * n
	u = int(s) // int(k) - 1
	u *= 10
	if n == 1:
		u += 1
	elif n == 2:
		u += 3
	elif n == 3:
		u += 6
	else:
		u += 10
	print(u)
	t -= 1


def get_data_a():
	n = int(input())
	digits = []
	for i in range(n):
		digits.append(int(input()))
	return digits

def flat_count(num):
	num_1 = num
	flat_counts = []
	dig_list = []
	stop = False
	for i in range(1, 10):
		if stop:
			break
		else:
			number = 0
			while len(str(number)) < 4:
				number = int(str(number) + str(i))
				if number == num_1:
					flat_counts.append(number)
					stop = True
					break
				else:
					flat_counts.append(number)
	for flat_num in flat_counts:
		for char in str(flat_num):
			dig_list.append(int(char))
	presses = len(dig_list)
	return presses

def press_count(data):
	results = []
	for num in data:
		results.append(flat_count(num))
	return results
data = get_data_a()
results = press_count(data)
print('\n'.join([str(res) for res in results]))


def solve(x):
	tt = [1, 3, 6, 10]
	dig = str(x)[0]
	return (int(dig) - 1) * 10 + tt[len(str(x)) - 1]

def run():
	(t, *_) = tuple(map(int, input().split()))
	for _ in range(t):
		print(solve(int(input())))
run()


T = int(input())
x = 1 + 2 + 3 + 4
while T:
	n = input()
	s = 0
	for i in range(len(n)):
		s += i + 1
	n = int(n[0])
	s = s + (n - 1) * x
	print(s)
	T -= 1


t = int(input())
for i in range(t):
	bor = input()
	tot = 0
	for j in range(len(bor)):
		tot += j + 1
	tot += (int(bor[0]) - 1) * 10
	print(tot)


import math

def print_result(ans):
	print(ans)

def sum_one_to_n(n):
	sum = 0
	for i in range(1, n + 1):
		sum += i
	return sum

def solve(x):
	if x == 1:
		num_digits = 1
	else:
		num_digits = math.ceil(math.log(x, 10))
	if num_digits == 1:
		first_digit = x
	else:
		first_digit = math.floor(x / 10 ** (num_digits - 1))
	sum_digits = (first_digit - 1) * 10 + sum_one_to_n(num_digits)
	return sum_digits
t = int(input())
for i in range(1, t + 1):
	x = int(input())
	ans = solve(x)
	print_result(ans)


from sys import stdin, stdout

def read_input():
	lines = []
	for line in stdin:
		if 'exit' == line.lower().rstrip():
			break
		lines.append(line.rstrip())
	return lines

def write(s):
	stdout.write(str(s) + '\n')

def finish():
	stdout.flush()
LIMIT = 10000
lines = read_input()
n = int(lines[0])
map = {}
count = 0
for digit in range(1, 10):
	tens = 1
	num = digit * tens
	while num < LIMIT:
		count += len(str(num))
		map[str(num)] = count
		digit *= 10
		num += digit
for case in range(1, n + 1):
	num = lines[case]
	write(map[num])
finish()


t = int(input())
for tc in range(t):
	x = int(input())
	dig = x % 10
	done = (1 + 2 + 3 + 4) * (dig - 1)
	done += 1
	if x >= 10 * dig:
		done += 2
	if x >= 100 * dig:
		done += 3
	if x >= 1000 * dig:
		done += 4
	print(done)


n = int(input())
ls = []
for m in range(n):
	f = list(input())
	ls.append(f)
for i in ls:
	x = ['1']
	res = 0
	while True:
		res += len(x)
		if x == i:
			print(res)
			break
		if len(x) == 4:
			x = [str(int(x[0]) + 1)]
		else:
			x.append(x[0])


n = int(input())
x = []
for _ in range(n):
	a = input()
	x.append(a)
for ad in x:
	p = int(ad) % 10
	print(int((p - 1) * 10 + len(ad) * (len(ad) + 1) / 2))


def fac(n):
	f = 0
	for i in range(n + 1):
		f += i
	return f

def solve(n):
	return (int(n[0]) - 1) * 10 + fac(len(n))
for _ in range(int(input())):
	print(solve(input()))


t = int(input())
while t:
	l = input()
	s = sum([i for i in range(1, len(l) + 1)])
	l = int(l)
	s += (l - 1) % 10 * 10
	print(s)
	t -= 1


w = []
n = int(input())
for i in range(1, 10):
	for j in range(1, 5):
		w.append(str(i) * j)
for i in range(n):
	s = input()
	cnt = 0
	for k in w:
		cnt += len(k)
		if s == k:
			print(cnt)


for _ in range(int(input())):
	n = int(input())
	d = [1, 11, 111, 1111, 2, 22, 222, 2222, 3, 33, 333, 3333, 4, 44, 444, 4444, 5, 55, 555, 5555, 6, 66, 666, 6666, 7, 77, 777, 7777, 8, 88, 888, 8888, 9, 99, 999, 9999]
	i = 0
	ans = 0
	while d[i] != n:
		ans += i % 4 + 1
		i += 1
	print(ans + i % 4 + 1)


n = int(input())
while n != 0:
	num = input()
	m = len(num)
	sum1 = int((int(num[0]) - 1) * 10 + m * (m + 1) / 2)
	n -= 1
	print(sum1)


t = int(input())

def countdig(n):
	return len(str(n))

def find(n):
	d = n % 10
	ans = countdig(n)
	return int(ans * (ans + 1) / 2) + 10 * (d - 1)
for x in range(t):
	n = int(input())
	print(find(n))


T = int(input())
arr = [1, 3, 6, 10]
for _ in range(T):
	x = int(input())
	print(10 * (int(str(x)[0:1]) - 1) + arr[int(len(str(x))) - 1])


t = int(input())
for _ in range(t):
	a = input()
	b = int(a[0])
	print((b - 1) * 10 + len(a) * (len(a) + 1) // 2)


t = int(input())
d = {1: 1, 2: 3, 3: 6, 4: 10}
for i in range(t):
	x = int(input())
	y = (x % 10 - 1) * 10 + d[len(str(x))]
	print(y)


for x in range(int(input())):
	n = int(input())
	k = len(str(n))
	print((n % 10 - 1) * 10 + k * (k + 1) // 2)


for _ in range(int(input())):
	n = int(input())
	g = str(n)
	first = int(g[0])
	(cnt_1, cnt_2, cnt_3, cnt_4) = (first, first, first, first)
	if len(g) == 1:
		cnt_1 += 1
	elif len(g) == 2:
		cnt_1 += 1
		cnt_2 += 1
	elif len(g) == 3:
		cnt_1 += 1
		cnt_2 += 1
		cnt_3 += 1
	else:
		cnt_1 += 1
		cnt_2 += 1
		cnt_3 += 1
		cnt_4 += 1
	print(cnt_1 * 1 + cnt_2 * 2 + cnt_3 * 3 + cnt_4 * 4 - 10)


import os
import sys
from io import BytesIO, IOBase
input = sys.stdin.readline

def inp():
	return int(input())

def inlt():
	return list(map(int, input().split()))

def insr():
	s = input()
	return list(s[:len(s) - 1])

def invr():
	return map(int, input().split())

def main():
	try:
		for _ in range(inp()):
			x = input()
			digit = int(x[0])
			print((digit - 1) * 10 + len(x) * (len(x) + 1) // 2)
	except Exception as e:
		print(e)
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
input = lambda : sys.stdin.readline().rstrip('\r\n')
main()


for t in range(int(input())):
	ip = input()
	vip = int(ip)
	valip = vip % 10
	l = len(ip)
	print((valip - 1) * 10 + l * (l + 1) // 2)


for _ in range(0, int(input())):
	x = input()
	var = int(x[0])
	l = int(len(x))
	if l == 1:
		ans = var * 10 - 9
		print(ans)
	elif l == 2:
		ans = var * 10 - 7
		print(ans)
	elif l == 3:
		ans = var * 10 - 4
		print(ans)
	elif l == 4:
		ans = var * 10
		print(ans)


from sys import stdin
input = stdin.readline
try:
	for i in range(int(input())):
		x = int(input())
		t = 0
		s = str(x)
		for j in range(1, 11):
			for k in range(1, 5):
				st = str(j) * k
				if st == s:
					t += len(st)
					break
				t += len(st)
			if st == s:
				print(t)
				t = 0
				break
except:
	pass


t = int(input())
for _ in range(t):
	n = int(input())
	ans = (n % 10 - 1) * 10
	for i in range(1, len(str(n)) + 1):
		ans += i
	print(ans)


n = int(input())
for i in range(n):
	x = input()
	if len(x) == 1:
		print((int(x[0]) - 1) * 10 + 1)
	elif len(x) == 2:
		print((int(x[0]) - 1) * 10 + 3)
	elif len(x) == 3:
		print((int(x[0]) - 1) * 10 + 6)
	else:
		print((int(x[0]) - 1) * 10 + 10)


d = int(input())
for o in range(d):
	a = int(input())
	x = 0
	q = 0
	for i in range(1, a % 10 + 1):
		z = 1
		x = 0
		e = 0
		while x != a:
			e = e + 1
			if z > 1000:
				break
			x = x + i * z
			z = z * 10
			q = q + e
	print(q)


for j in range(int(input())):
	a = input()
	g = int(a[0])
	if g != 1:
		if len(a) == 1:
			print((g - 1) * 10 + 1)
		if len(a) == 2:
			print((g - 1) * 10 + 3)
		if len(a) == 3:
			print((g - 1) * 10 + 6)
		if len(a) == 4:
			print((g - 1) * 10 + 10)
	elif a == '1':
		print(1)
	elif a == '11':
		print(3)
	elif a == '111':
		print(6)
	else:
		print(10)


import bisect
import collections
import copy
import functools
import heapq
import itertools
import math
import random
import re
import sys
import time
import string
from typing import List
sys.setrecursionlimit(99999)

def solve():
	sn = input().strip()
	p = (int(sn[0]) - 1) * 10
	s = (1 + len(sn)) * len(sn) // 2
	return p + s
t = int(input())
for _ in range(t):
	print(solve())


t = int(input())
for _ in range(t):
	x = int(input())
	count = (x % 10 - 1) * 10
	k = 1
	while x // 10 >= 1:
		count += k
		x = x // 10
		k += 1
	print(count + k)


for i in range(int(input())):
	n = input()
	a = int(n[0]) - 1
	c = a * 10
	l = len(n)
	c += l * (l + 1) // 2
	print(c)


import math
import random
import heapq, bisect
import sys
from collections import deque, defaultdict
from fractions import Fraction
import sys
from collections import defaultdict
mod = 10 ** 9 + 7
mod1 = 998244353
import os
import sys
from io import BytesIO, IOBase
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
input = lambda : sys.stdin.readline().rstrip('\r\n')

class TreeNode:

	def __init__(self, k, v):
		self.key = k
		self.value = v
		self.left = None
		self.right = None
		self.parent = None
		self.height = 1
		self.num_left = 1
		self.num_total = 1

class AvlTree:

	def __init__(self):
		self._tree = None

	def add(self, k, v):
		if not self._tree:
			self._tree = TreeNode(k, v)
			return
		node = self._add(k, v)
		if node:
			self._rebalance(node)

	def _add(self, k, v):
		node = self._tree
		while node:
			if k < node.key:
				if node.left:
					node = node.left
				else:
					node.left = TreeNode(k, v)
					node.left.parent = node
					return node.left
			elif node.key < k:
				if node.right:
					node = node.right
				else:
					node.right = TreeNode(k, v)
					node.right.parent = node
					return node.right
			else:
				node.value = v
				return

	@staticmethod
	def get_height(x):
		return x.height if x else 0

	@staticmethod
	def get_num_total(x):
		return x.num_total if x else 0

	def _rebalance(self, node):
		n = node
		while n:
			lh = self.get_height(n.left)
			rh = self.get_height(n.right)
			n.height = max(lh, rh) + 1
			balance_factor = lh - rh
			n.num_total = 1 + self.get_num_total(n.left) + self.get_num_total(n.right)
			n.num_left = 1 + self.get_num_total(n.left)
			if balance_factor > 1:
				if self.get_height(n.left.left) < self.get_height(n.left.right):
					self._rotate_left(n.left)
				self._rotate_right(n)
			elif balance_factor < -1:
				if self.get_height(n.right.right) < self.get_height(n.right.left):
					self._rotate_right(n.right)
				self._rotate_left(n)
			else:
				n = n.parent

	def _remove_one(self, node):
		replacement = node.left or node.right
		if node.parent:
			if AvlTree._is_left(node):
				node.parent.left = replacement
			else:
				node.parent.right = replacement
			replacement.parent = node.parent
			node.parent = None
		else:
			self._tree = replacement
			replacement.parent = None
		node.left = None
		node.right = None
		node.parent = None
		self._rebalance(replacement)

	def _remove_leaf(self, node):
		if node.parent:
			if AvlTree._is_left(node):
				node.parent.left = None
			else:
				node.parent.right = None
			self._rebalance(node.parent)
		else:
			self._tree = None
		node.parent = None
		node.left = None
		node.right = None

	def remove(self, k):
		node = self._get_node(k)
		if not node:
			return
		if AvlTree._is_leaf(node):
			self._remove_leaf(node)
			return
		if node.left and node.right:
			nxt = AvlTree._get_next(node)
			node.key = nxt.key
			node.value = nxt.value
			if self._is_leaf(nxt):
				self._remove_leaf(nxt)
			else:
				self._remove_one(nxt)
			self._rebalance(node)
		else:
			self._remove_one(node)

	def get(self, k):
		node = self._get_node(k)
		return node.value if node else -1

	def _get_node(self, k):
		if not self._tree:
			return None
		node = self._tree
		while node:
			if k < node.key:
				node = node.left
			elif node.key < k:
				node = node.right
			else:
				return node
		return None

	def get_at(self, pos):
		x = pos + 1
		node = self._tree
		while node:
			if x < node.num_left:
				node = node.left
			elif node.num_left < x:
				x -= node.num_left
				node = node.right
			else:
				return (node.key, node.value)
		raise IndexError('Out of ranges')

	@staticmethod
	def _is_left(node):
		return node.parent.left and node.parent.left == node

	@staticmethod
	def _is_leaf(node):
		return node.left is None and node.right is None

	def _rotate_right(self, node):
		if not node.parent:
			self._tree = node.left
			node.left.parent = None
		elif AvlTree._is_left(node):
			node.parent.left = node.left
			node.left.parent = node.parent
		else:
			node.parent.right = node.left
			node.left.parent = node.parent
		bk = node.left.right
		node.left.right = node
		node.parent = node.left
		node.left = bk
		if bk:
			bk.parent = node
		node.height = max(self.get_height(node.left), self.get_height(node.right)) + 1
		node.num_total = 1 + self.get_num_total(node.left) + self.get_num_total(node.right)
		node.num_left = 1 + self.get_num_total(node.left)

	def _rotate_left(self, node):
		if not node.parent:
			self._tree = node.right
			node.right.parent = None
		elif AvlTree._is_left(node):
			node.parent.left = node.right
			node.right.parent = node.parent
		else:
			node.parent.right = node.right
			node.right.parent = node.parent
		bk = node.right.left
		node.right.left = node
		node.parent = node.right
		node.right = bk
		if bk:
			bk.parent = node
		node.height = max(self.get_height(node.left), self.get_height(node.right)) + 1
		node.num_total = 1 + self.get_num_total(node.left) + self.get_num_total(node.right)
		node.num_left = 1 + self.get_num_total(node.left)

	@staticmethod
	def _get_next(node):
		if not node.right:
			return node.parent
		n = node.right
		while n.left:
			n = n.left
		return n

class SegmentTree1:

	def __init__(self, data, default=300006, func=lambda a, b: min(a, b)):
		self._default = default
		self._func = func
		self._len = len(data)
		self._size = _size = 1 << (self._len - 1).bit_length()
		self.data = [default] * (2 * _size)
		self.data[_size:_size + self._len] = data
		for i in reversed(range(_size)):
			self.data[i] = func(self.data[i + i], self.data[i + i + 1])

	def __delitem__(self, idx):
		self[idx] = self._default

	def __getitem__(self, idx):
		return self.data[idx + self._size]

	def __setitem__(self, idx, value):
		idx += self._size
		self.data[idx] = value
		idx >>= 1
		while idx:
			self.data[idx] = self._func(self.data[2 * idx], self.data[2 * idx + 1])
			idx >>= 1

	def __len__(self):
		return self._len

	def query(self, start, stop):
		if start == stop:
			return self.__getitem__(start)
		stop += 1
		start += self._size
		stop += self._size
		res = self._default
		while start < stop:
			if start & 1:
				res = self._func(res, self.data[start])
				start += 1
			if stop & 1:
				stop -= 1
				res = self._func(res, self.data[stop])
			start >>= 1
			stop >>= 1
		return res

	def __repr__(self):
		return 'SegmentTree({0})'.format(self.data)

class SegmentTree:

	def __init__(self, data, default=0, func=lambda a, b: a + b):
		self._default = default
		self._func = func
		self._len = len(data)
		self._size = _size = 1 << (self._len - 1).bit_length()
		self.data = [default] * (2 * _size)
		self.data[_size:_size + self._len] = data
		for i in reversed(range(_size)):
			self.data[i] = func(self.data[i + i], self.data[i + i + 1])

	def __delitem__(self, idx):
		self[idx] = self._default

	def __getitem__(self, idx):
		return self.data[idx + self._size]

	def __setitem__(self, idx, value):
		idx += self._size
		self.data[idx] = value
		idx >>= 1
		while idx:
			self.data[idx] = self._func(self.data[2 * idx], self.data[2 * idx + 1])
			idx >>= 1

	def __len__(self):
		return self._len

	def query(self, start, stop):
		if start == stop:
			return self.__getitem__(start)
		stop += 1
		start += self._size
		stop += self._size
		res = self._default
		while start < stop:
			if start & 1:
				res = self._func(res, self.data[start])
				start += 1
			if stop & 1:
				stop -= 1
				res = self._func(res, self.data[stop])
			start >>= 1
			stop >>= 1
		return res

	def __repr__(self):
		return 'SegmentTree({0})'.format(self.data)

class Factorial:

	def __init__(self, MOD):
		self.MOD = MOD
		self.factorials = [1, 1]
		self.invModulos = [0, 1]
		self.invFactorial_ = [1, 1]

	def calc(self, n):
		if n <= -1:
			print('Invalid argument to calculate n!')
			print('n must be non-negative value. But the argument was ' + str(n))
			exit()
		if n < len(self.factorials):
			return self.factorials[n]
		nextArr = [0] * (n + 1 - len(self.factorials))
		initialI = len(self.factorials)
		prev = self.factorials[-1]
		m = self.MOD
		for i in range(initialI, n + 1):
			prev = nextArr[i - initialI] = prev * i % m
		self.factorials += nextArr
		return self.factorials[n]

	def inv(self, n):
		if n <= -1:
			print('Invalid argument to calculate n^(-1)')
			print('n must be non-negative value. But the argument was ' + str(n))
			exit()
		p = self.MOD
		pi = n % p
		if pi < len(self.invModulos):
			return self.invModulos[pi]
		nextArr = [0] * (n + 1 - len(self.invModulos))
		initialI = len(self.invModulos)
		for i in range(initialI, min(p, n + 1)):
			next = -self.invModulos[p % i] * (p // i) % p
			self.invModulos.append(next)
		return self.invModulos[pi]

	def invFactorial(self, n):
		if n <= -1:
			print('Invalid argument to calculate (n^(-1))!')
			print('n must be non-negative value. But the argument was ' + str(n))
			exit()
		if n < len(self.invFactorial_):
			return self.invFactorial_[n]
		self.inv(n)
		nextArr = [0] * (n + 1 - len(self.invFactorial_))
		initialI = len(self.invFactorial_)
		prev = self.invFactorial_[-1]
		p = self.MOD
		for i in range(initialI, n + 1):
			prev = nextArr[i - initialI] = prev * self.invModulos[i % p] % p
		self.invFactorial_ += nextArr
		return self.invFactorial_[n]

class Combination:

	def __init__(self, MOD):
		self.MOD = MOD
		self.factorial = Factorial(MOD)

	def ncr(self, n, k):
		if k < 0 or n < k:
			return 0
		k = min(k, n - k)
		f = self.factorial
		return f.calc(n) * f.invFactorial(max(n - k, k)) * f.invFactorial(min(k, n - k)) % self.MOD

def powm(a, n, m):
	if a == 1 or n == 0:
		return 1
	if n % 2 == 0:
		s = powm(a, n // 2, m)
		return s * s % m
	else:
		return a * powm(a, n - 1, m) % m

def sort_list(list1, list2):
	zipped_pairs = zip(list2, list1)
	z = [x for (_, x) in sorted(zipped_pairs)]
	return z

def product(l):
	por = 1
	for i in range(len(l)):
		por *= l[i]
	return por

def binarySearchCount(arr, n, key):
	left = 0
	right = n - 1
	count = 0
	while left <= right:
		mid = int((right + left) / 2)
		if arr[mid] < key:
			count = mid + 1
			left = mid + 1
		else:
			right = mid - 1
	return count

def countdig(n):
	c = 0
	while n > 0:
		n //= 10
		c += 1
	return c

def binary(x, length):
	y = bin(x)[2:]
	return y if len(y) >= length else '0' * (length - len(y)) + y

def countGreater(arr, n, k):
	l = 0
	r = n - 1
	leftGreater = n
	while l <= r:
		m = int(l + (r - l) / 2)
		if arr[m] > k:
			leftGreater = m
			r = m - 1
		else:
			l = m + 1
	return n - leftGreater

class TrieNode:

	def __init__(self):
		self.children = [None] * 26
		self.isEndOfWord = False

class Trie:

	def __init__(self):
		self.root = self.getNode()

	def getNode(self):
		return TrieNode()

	def _charToIndex(self, ch):
		return ord(ch) - ord('a')

	def insert(self, key):
		pCrawl = self.root
		length = len(key)
		for level in range(length):
			index = self._charToIndex(key[level])
			if not pCrawl.children[index]:
				pCrawl.children[index] = self.getNode()
			pCrawl = pCrawl.children[index]
		pCrawl.isEndOfWord = True

	def search(self, key):
		pCrawl = self.root
		length = len(key)
		for level in range(length):
			index = self._charToIndex(key[level])
			if not pCrawl.children[index]:
				return False
			pCrawl = pCrawl.children[index]
		return pCrawl != None and pCrawl.isEndOfWord

class Node:

	def __init__(self, data):
		self.data = data
		self.count = 0
		self.left = None
		self.right = None

class BinaryTrie:

	def __init__(self):
		self.root = Node(0)

	def insert(self, pre_xor):
		self.temp = self.root
		for i in range(31, -1, -1):
			val = pre_xor & 1 << i
			if val:
				if not self.temp.right:
					self.temp.right = Node(0)
				self.temp = self.temp.right
				self.temp.count += 1
			if not val:
				if not self.temp.left:
					self.temp.left = Node(0)
				self.temp = self.temp.left
				self.temp.count += 1
		self.temp.data = pre_xor

	def query(self, xor):
		self.temp = self.root
		for i in range(31, -1, -1):
			val = xor & 1 << i
			if not val:
				if self.temp.left and self.temp.left.count > 0:
					self.temp = self.temp.left
				elif self.temp.right:
					self.temp = self.temp.right
			elif self.temp.right and self.temp.right.count > 0:
				self.temp = self.temp.right
			elif self.temp.left:
				self.temp = self.temp.left
			self.temp.count -= 1
		return xor ^ self.temp.data
for ik in range(int(input())):
	s = input()
	w = [0, 1, 3, 6, 10]
	print((int(s[0]) - 1) * 10 + w[len(s)])


x = int(input())
for i in range(x):
	p = 0
	m = input()
	p += (1 + 2 + 3 + 4) * (int(m[0]) - 1)
	if len(m) == 1:
		p += 1
	elif len(m) == 2:
		p += 3
	elif len(m) == 3:
		p += 6
	else:
		p += 10
	print(p)


t = int(input())
for z in range(t):
	n = input()
	len_n = len(n)
	ans = (int(n[0]) - 1) * 10 + len_n * (len_n + 1) // 2
	print(ans)


n = int(input())
for i in range(n):
	m = int(input())
	m = str(m)
	m1 = int(m[0])
	n = len(m)
	if n == 4:
		c = 10
	elif n == 3:
		c = 6
	elif n == 2:
		c = 3
	elif n == 1:
		c = 1
	print((m1 - 1) * 10 + c)


for i in range(int(input())):
	a = input()
	if len(a) == 1:
		a1 = 1
	elif len(a) == 2:
		a1 = 3
	elif len(a) == 3:
		a1 = 6
	else:
		a1 = 10
	print(10 * (int(a[0]) - 1) + a1)


import sys, io, os, time
from collections import defaultdict
from collections import Counter
from collections import deque
from itertools import combinations
from itertools import permutations
import bisect, math, heapq
alphabet = 'abcdefghijklmnopqrstuvwxyz'
input = sys.stdin.readline
for ii in range(int(input())):
	x = int(input())
	digs = [1, 2, 3, 4]
	last = x % 10
	ans = (last - 1) * sum(digs)
	ans += sum(digs[:len(str(x))])
	print(ans)


from sys import stdin, stdout
from collections import *
st = lambda : list(stdin.readline().strip())
li = lambda : list(map(int, stdin.readline().split()))
mp = lambda : map(int, stdin.readline().split())
inp = lambda : int(stdin.readline())
pr = lambda n: stdout.write(str(n) + '\n')
mod = 1000000007
INF = float('inf')
l = []
for i in range(1, 10):
	l.append(str(i))
	l.append(2 * str(i))
	l.append(3 * str(i))
	l.append(4 * str(i))

def solve():
	n = input()
	n = str(n)
	a = l.index(n)
	c = 1
	ans = 0
	for i in range(a + 1):
		ans += len(l[i])
	print(ans)
for _ in range(inp()):
	solve()


num = int(input())
for m in range(num):
	t = int(input())
	li = [int(x) for x in str(t)]
	i = 1
	while i <= 9:
		if li[0] == i:
			x = i - 1
			if len(li) == 1:
				y = 1
			if len(li) == 2:
				y = 3
			if len(li) == 3:
				y = 6
			if len(li) == 4:
				y = 10
		i += 1
	print(x * 10 + y)


import sys
import math
tests = int(sys.stdin.readline().split()[0])
for test in range(tests):
	x = int(sys.stdin.readline().split()[0])
	if x == 1:
		print(1)
		continue
	key_pressed = 0
	digit = 0
	test_number = 1
	while test_number != x:
		digit += 1
		test_number = 0
		for k in range(4):
			test_number += digit * math.pow(10, k)
			key_pressed += int(math.log(test_number, 10)) + 1
			if test_number == x:
				break
	print(key_pressed)


t = int(input())
A = [1, 3, 6, 10]
for i in range(0, t):
	n = str(input())
	print(10 * (int(n[0]) - 1) + A[len(n) - 1])


for _ in range(int(input())):
	n = input()
	c = int(n[0])
	ans = (c - 1) * 10
	k = len(n)
	for i in range(1, k + 1):
		ans += i
	print(ans)


from math import log10

def solve(n):
	temp = {1: 1, 2: 3, 3: 6, 4: 10}
	diglen = int(log10(n)) + 1
	if n == 1 or n == 11 or n == 111 or (n == 1111):
		return temp[diglen]
	lastdigit = n % 10
	return (lastdigit - 1) * 10 + temp[diglen]

def main():
	TT = int(input())
	print(*[solve(int(input())) for i in range(TT)], sep='\n')
main()


cases = int(input())
for _ in range(cases):
	x = input()
	t = int(x[0])
	print((t - 1) * (1 + 2 + 3 + 4) + sum(range(len(x) + 1)))


for _ in range(int(input())):
	p = int(input())
	i = p % 10
	q = str(p)
	l = len(q)
	sum = (i - 1) * 10 + l * (l + 1) / 2
	print(int(sum))


def main():
	for _ in range(int(input())):
		x = int(input())
		w = 0
		for i in range(int(str(x)[0])):
			j = str(i + 1)
			t = j
			while int(t) <= 10000:
				if t[0] != str(x)[0]:
					w += len(t)
					t += j
				elif int(t) <= x:
					w += len(t)
					t += j
				else:
					break
		print(w)
main()


import sys
infile = sys.stdin
next(infile)
for line in infile:
	n = int(line)
	k = n % 10
	ans = 0
	ans += (k - 1) * 10
	m = len(str(n))
	for i in range(m + 1):
		ans += i
	print(ans)


for _ in range(int(input())):
	x = int(input())
	d = x % 10
	count = (d - 1) * 10
	count_d = 0
	while x > 0:
		count_d = count_d + 1
		x = x // 10
	for i in range(1, count_d + 1):
		count = count + i
	print(count)


for _ in range(int(input())):
	n = input()
	p = 0
	for i in set(n):
		x = i
	x = int(x) - 1
	p = x * 10
	if len(n) == 1:
		p += 1
	elif len(n) == 2:
		p += 3
	elif len(n) == 3:
		p += 6
	elif len(n) == 4:
		p += 10
	print(p)


for _ in range(int(input())):
	x = int(input())
	f = False
	ans = 0
	for i in range(1, 10):
		for j in range(1, 5):
			if int(str(i) * j) == x:
				ans += j
				f = True
				break
			else:
				ans += j
		if f:
			break
	print(ans)


for x in range(int(input())):
	a = input()
	b = 10 * (int(a[-1]) - 1) + (len(a) - 1 >= 0) * 1 + (len(a) - 2 >= 0) * 2 + (len(a) - 3 >= 0) * 3 + (len(a) - 4 == 0) * 4
	print(b)


import os

def main():
	test_cases = int(input())
	ans = [None] * test_cases
	for t in range(test_cases):
		s = list(map(int, list(input())))
		res = 0
		res = int((s[0] - 1) * 10 + len(s) * (len(s) + 1) / 2)
		ans[t] = res
	os.write(1, '\n'.join(map(str, ans)).encode())
main()


t = int(input())
for _ in range(t):
	n = input()
	m = len(n)
	a = int(n[0]) - 1
	ans = a * 10 + m * (m + 1) / 2
	print(int(ans))


try:
	for _ in range(int(input())):
		n = input()
		f = int(n[0])
		lt = len(n)
		sum = (f - 1) * 10 + lt * (lt + 1) / 2
		print(int(sum))
except:
	print('err')


t = int(input())
for i in range(t):
	a = input()
	print(int(10 * (int(a[0]) - 1) + 0.5 * len(a) * (len(a) + 1)))


for i in range(int(input())):
	n = int(input())
	lis = list(str(n))
	l = len(lis)
	print(int(10 * (int(lis[0]) - 1) + l * (l + 1) / 2))


y = 0
for i in range(int(input())):
	Str = input()
	x = list(map(int, Str))
	y = 10 * (x[0] - 1) + len(x) * (len(x) + 1) / 2
	print(int(y))


for _ in range(int(input())):
	s = list(input())
	n = int(s[0]) % 10
	digit = len(s)
	if digit == 1:
		print(n * 1 + (n - 1) * 2 + (n - 1) * 3 + (n - 1) * 4)
	elif digit == 2:
		print(n * 1 + n * 2 + (n - 1) * 3 + (n - 1) * 4)
	elif digit == 3:
		print(n * 1 + n * 2 + n * 3 + (n - 1) * 4)
	else:
		print(n * 1 + n * 2 + n * 3 + n * 4)


import math

def count_digits(x):
	digits = 0
	while x != 0:
		digits += 1
		x //= 10
	return digits
t = int(input())
for t_i in range(t):
	answerer = int(input())
	total_digits = 0
	digit = 1
	x = digit
	while x != answerer:
		total_digits += count_digits(x)
		x *= 10
		x += digit
		if x >= 10000:
			digit += 1
			x = digit
	total_digits += count_digits(x)
	print(total_digits)


try:
	t = int(input())
	while t:
		t = -1
		s = list(map(int, input()))
		ln = len(s)
		print(10 * (s[0] - 1) + ln * (ln + 1) // 2)
except:
	pass


import math
import string
import random
from random import randrange
from collections import deque
from collections import defaultdict

def solve(n):
	ans = 0
	k = n % 10
	ans += 10 * (k - 1)
	f = len(str(n))
	for i in range(1, f + 1):
		ans += i
	print(ans)
	return

def main():
	t = int(input())
	while t > 0:
		t -= 1
		n = int(input())
		solve(n)
	return

def test():
	arr_size = 25
	test_cases = 100
	min_range = -100
	max_range = 100
	str_size = 30
	step = 1
	for i in range(test_cases):
		k = []
		for j in range(arr_size):
			num = randrange(min_range, max_range, step)
			k.append(num)
		solve(n, arr)
		print('<-------- DEBUG ----------->')
	return
main()


for i in range(int(input())):
	n = input()
	c = int(n[0])
	count = 10 * c
	if len(n) == 4:
		print(count)
	elif len(n) == 3:
		print(count - 4)
	elif len(n) == 2:
		print(count - 7)
	else:
		print(count - 9)


t = int(input())
while t > 0:
	s = str(input())
	d = int(s[0])
	f = d * 10
	if len(s) == 1 and 2 <= d and (d <= 9):
		print(10 * d + 1 - 10)
	elif len(s) == 4:
		print(f)
	elif len(s) == 3:
		print(f - 4)
	elif len(s) == 2:
		print(f - 7)
	elif s == '1':
		print(s)
	t -= 1


def solve(p):
	ans = (int(p[0]) - 1) * 10
	for x in range(1, len(p) + 1):
		ans += x
	return ans
t = int(input())
for x in range(t):
	p = input()
	print(solve(p))


lookup = {1: 1, 2: 3, 3: 6, 4: 10}
for _ in range(int(input())):
	N = list(map(int, list(input())))
	fir = N[0]
	ll = len(N)
	print(10 * (fir - 1) + lookup[ll])


def count_floor(n):
	stop = int(str(n)[0])
	count = 0
	for i in range(1, stop):
		for j in range(1, 5):
			add = str(i) * j
			count += len(add)
	t = len(str(n))
	for i in range(t):
		add = str(stop) * (i + 1)
		count += len(add)
	return count
t = int(input())
for i in range(t):
	n = input()
	print(count_floor(int(n)))


n = int(input())
for i in range(n):
	n = input()
	x = int(n[0])
	a = 10
	z = x - 1
	if len(n) == 1:
		print(z * a + 1)
	elif len(n) == 2:
		print(z * a + 3)
	elif len(n) == 3:
		print(z * a + 6)
	elif len(n) == 4:
		print(z * a + 10)


def digits(x):
	c = 0
	while x > 0:
		x = x // 10
		c += 1
	return c
for _ in range(int(input())):
	n = int(input())
	o = n % 10
	d = digits(n)
	r = (o - 1) * 10 + d * (d + 1) // 2
	print(r)


array = []
for i in range(1, 10):
	array.append(i)
	num = i * 10 + i
	array.append(num)
	num = num * 10 + i
	array.append(num)
	num = num * 10 + i
	array.append(num)
t = int(input())
while t > 0:
	t -= 1
	x = int(input())
	count = 0
	for i in range(len(array)):
		count += i % 4 + 1
		if array[i] == x:
			break
	print(count)


t = int(input())
h = [1, 11, 111, 1111]
for _ in range(t):
	b = int(input())
	r = 0
	for i in range(100000):
		x = h[i % 4] * (i // 4 + 1)
		if x == b:
			r = i // 4 * 10 + [1, 3, 6, 10][i % 4]
			break
	print(r)


N = int(input())
for _ in range(N):
	n = input()
	c = 10 * (int(n[0]) - 1)
	for i in range(1, len(n) + 1):
		c += i
	print(c)


t = int(input())
for i in range(t):
	x = int(input())
	z = 0
	for j in range(1, 10):
		c = 0
		for k in range(1, 5):
			c = c * 10 + j
			z += k
			if c == x:
				print(z)
				break


n = int(input())
for i in range(n):
	x = int(input())
	if x < 10:
		if x == 1:
			print(1)
		else:
			y = 10 * (x - 1)
			print(y + 1)
	else:
		r = x % 10
		if r == 1:
			x = str(x)
			y = int(len(x) * (len(x) + 1) / 2)
			print(y)
		else:
			y = 10 * (r - 1)
			x = str(x)
			z = int(len(x) * (len(x) + 1) / 2)
			print(y + z)


kv = []
for i in range(1, 10):
	n = 1
	while n <= 4:
		kv.append(int(str(i) * n))
		n += 1
for i in range(int(input())):
	check = int(input())
	sum = 0
	i = 0
	while check != kv[i]:
		sum += len(str(kv[i]))
		i += 1
	sum += len(str(kv[i]))
	print(sum)


import sys
num = int(sys.stdin.readline())
s = [1, 3, 6, 10]
for i in range(num):
	t = sys.stdin.readline().strip()
	print((int(t[0]) - 1) * 10 + s[len(t) - 1])


import sys, math, cmath, time
start_time = time.time()

def solve():
	x = inp()
	print((x % 10 - 1) * 10 + len(str(x)) * (len(str(x)) - 1) // 2 + len(str(x)))

def main():
	global tt
	if not ONLINE_JUDGE:
		sys.stdin = open('input.txt', 'r')
		sys.stdout = open('output.txt', 'w')
	t = 1
	t = inp()
	for tt in range(1, t + 1):
		solve()
	if not ONLINE_JUDGE:
		print('Time Elapsed :', time.time() - start_time, 'seconds')
		sys.stdout.close()

def inp():
	return int(input())

def inlt():
	return list(map(int, input().split()))

def insr():
	return input().strip()

def invr():
	return map(int, input().split())

def counter(a):
	q = [0] * max(a)
	for i in range(len(a)):
		q[a[i] - 1] = q[a[i] - 1] + 1
	return q

def counter_elements(a):
	q = dict()
	for i in range(len(a)):
		if a[i] not in q:
			q[a[i]] = 0
		q[a[i]] = q[a[i]] + 1
	return q

def string_counter(a):
	q = [0] * 26
	for i in range(len(a)):
		q[ord(a[i]) - 97] = q[ord(a[i]) - 97] + 1
	return q

def factorial(n, m=1000000007):
	q = 1
	for i in range(n):
		q = q * (i + 1) % m
	return q

def factors(n):
	q = []
	for i in range(1, int(n ** 0.5) + 1):
		if n % i == 0:
			q.append(i)
			q.append(n // i)
	return list(sorted(list(set(q))))

def prime_factors(n):
	q = []
	while n % 2 == 0:
		q.append(2)
		n = n // 2
	for i in range(3, int(n ** 0.5) + 1, 2):
		while n % i == 0:
			q.append(i)
			n = n // i
	if n > 2:
		q.append(n)
	return list(sorted(q))

def transpose(a):
	(n, m) = (len(a), len(a[0]))
	b = [[0] * n for i in range(m)]
	for i in range(m):
		for j in range(n):
			b[i][j] = a[j][i]
	return b

def power_two(x):
	return x and (not x & x - 1)

def ceil(a, b):
	return -(-a // b)

def seive(n):
	a = [1]
	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 = p + 1
	for p in range(2, n + 1):
		if prime[p]:
			a.append(p)
	return a
ONLINE_JUDGE = __debug__
if ONLINE_JUDGE:
	input = sys.stdin.readline
main()


n = int(input())
res = []
for _ in range(n):
	i = input()
	res.append((int(i[0]) - 1) * 10 + len(i) * (len(i) + 1) // 2)
for i in res:
	print(i)


from collections import Counter
import string
import math
import sys
from fractions import Fraction

def array_int():
	return [int(i) for i in sys.stdin.readline().split()]

def vary(arrber_of_variables):
	if arrber_of_variables == 1:
		return int(sys.stdin.readline())
	if arrber_of_variables >= 2:
		return map(int, sys.stdin.readline().split())

def makedict(var):
	return dict(Counter(var))

def printDivisors(n):
	divisors = []
	i = 1
	while i <= math.sqrt(n):
		if n % i == 0:
			if n // i == i:
				divisors.append(i)
			else:
				divisors.extend((i, n // i))
		i = i + 1
	return divisors

def countTotalBits(num):
	binary = bin(num)[2:]
	return len(binary)

def isPrime(n):
	if n <= 1:
		return False
	if n <= 3:
		return True
	if n % 2 == 0 or n % 3 == 0:
		return False
	i = 5
	while i * i <= n:
		if n % i == 0 or n % (i + 2) == 0:
			return False
		i = i + 6
	return True
for _ in range(vary(1)):
	n = vary(1)
	t = len(str(n))
	ans = 0
	while t > 0:
		ans += t
		t -= 1
	print((n % 10 - 1) * 10 + ans)


for _ in range(int(input())):
	x = int(input())
	ans = 0
	flag = 0
	for i in range(1, 10):
		cur = 0
		for j in range(1, 5):
			cur = cur * 10 + i
			ans += j
			if cur == x:
				flag = 1
				break
		if flag:
			break
	print(ans)


for t in range(int(input())):
	n = int(input())
	sum = 1
	num = 1
	x = 1
	while num != n:
		if num // 1000 != 0:
			x += 1
			num = x
		else:
			num = num * 10 + x
		sum += len(str(num))
	print(sum)


import sys
si = sys.stdin.readline
t = int(si())
while t:
	t -= 1
	st = si()[:-1]
	(num, l, cnt) = (int(st[0]), len(st), 0)
	for _ in range(1, num):
		cnt += 10
	for i in range(l):
		cnt += i + 1
	print(cnt)


for c in range(int(input())):
	a = int(input())
	c = a % 10
	l = []
	for n in str(a):
		l.append(n)
	if c == 1:
		if len(l) == 1:
			ans = 1
		elif len(l) == 2:
			ans = 3
		elif len(l) == 3:
			ans = 6
		else:
			ans = 10
		print(ans)
	else:
		if len(l) == 1:
			ans2 = 1
		elif len(l) == 2:
			ans2 = 3
		elif len(l) == 3:
			ans2 = 6
		else:
			ans2 = 10
		op = c - 1
		ans1 = op * 10
		print(ans1 + ans2)


import math
for o in range(int(input())):
	n = int(input())
	bs = 10
	bl = [1, 11, 111, 1111]
	if int(math.log10(n) + 1) == 1:
		a = n // bl[0]
		print((a - 1) * bs + 1)
	elif int(math.log10(n) + 1) == 2:
		a = n // bl[1]
		s = (a - 1) * bs + 3
		print(s)
	elif int(math.log10(n) + 1) == 3:
		a = n // bl[2]
		s = (a - 1) * bs + 6
		print(s)
	else:
		a = n // bl[3]
		s = a * bs
		print(s)


from __future__ import division, print_function
import bisect
import math
import heapq
import itertools
import sys
from collections import deque
from atexit import register
from collections import Counter
from functools import reduce
if sys.version_info[0] < 3:
	from io import BytesIO as stream
else:
	from io import StringIO as stream
if sys.version_info[0] < 3:

	class dict(dict):

		def items(self):
			return dict.iteritems(self)

		def keys(self):
			return dict.iterkeys(self)

		def values(self):
			return dict.itervalues(self)
	input = raw_input
	range = xrange
	filter = itertools.ifilter
	map = itertools.imap
	zip = itertools.izip

def sync_with_stdio(sync=True):
	global input, flush
	if sync:
		flush = sys.stdout.flush
	else:
		sys.stdin = stream(sys.stdin.read())
		input = lambda : sys.stdin.readline().rstrip('\r\n')
		sys.stdout = stream()
		register(lambda : sys.__stdout__.write(sys.stdout.getvalue()))

def main():
	for _ in range(int(input())):
		n = input()
		lol = int(n[0]) - 1
		ln = len(n)
		print(10 * lol + ln * (ln + 1) // 2)
sync_with_stdio(False)
main()


t = int(input())
for i in range(t):
	x = input()
	d = int(x[0])
	k = (d - 1) * 10 + len(x)
	c = len(x) - 1
	while c:
		k += c
		c -= 1
	print(k)


def main():
	n = int(input())
	ans = list()
	for _ in range(n):
		k = int(input())
		sim_k = (1 + len(str(k))) * len(str(k)) // 2
		sim_before = 10 * (k % 10 - 1)
		ans.append(sim_k + sim_before)
	for item in ans:
		print(item)
main()


for _ in range(int(input())):
	n = int(input())
	ans = 0
	f = False
	for i in range(1, 10):
		for j in range(1, 5):
			a = int(str(i) * j)
			ans += j
			if a == n:
				f = True
				break
		if f == True:
			break
	print(ans)


t = int(input())
for i in range(t):
	s = input()
	print((int(s[0]) - 1) * 10 + 1 * (len(s) == 1) + 3 * (len(s) == 2) + 6 * (len(s) == 3) + 10 * (len(s) == 4))


n = int(input())
while n != 0:
	x = input()
	z = int(x)
	kq = (z % 10 - 1) * 10 + len(x) * (len(x) + 1) / 2
	print(int(kq))
	n = n - 1


import sys
from collections import defaultdict
from sys import maxsize

def ini():
	return int(sys.stdin.readline())

def inp():
	return map(int, sys.stdin.readline().strip().split())

def li():
	return list(map(int, sys.stdin.readline().strip().split()))
for _ in range(ini()):
	n = ini()
	t = str(n)
	l = [1, 2, 3, 4]
	s = 0
	s += (int(t[-1]) - 1) * 10
	for i in range(len(t)):
		s += l[i]
	print(s)


t = int(input())
for i in range(t):
	x = input()
	L = list()
	for i in range(1, 10):
		for j in range(1, 5):
			L.append(str(i) * j)
		try:
			assert x in L
			F = L[0:L.index(x) + 1]
			K = [len(F[i]) for i in range(L.index(x) + 1)]
			print(sum(K))
			break
		except:
			continue


t = int(input())
for i in range(t):
	n = input()
	ch = n[0]
	number = int(ch)
	total = (number - 1) * 10
	l = len(n)
	s = l * (l + 1) // 2
	total += s
	print(total)


a = int(input())
for i in range(a):
	c = int(input())
	print(10 * (int(str(c)[0]) - 1) + (len(str(c)) + 1) * len(str(c)) // 2)


def process(a):
	N = 10000
	count = 0
	flag = 0
	for i in range(1, 10):
		num = i
		while num <= N:
			count += len(str(num))
			if num == a:
				flag = 1
				break
			num = num * 10 + i
		if flag == 1:
			break
	print(count)
for _ in range(int(input())):
	a = int(input())
	process(a)


t = int(input())
for i in range(t):
	a = 0
	c = 0
	b = input()
	for i in range(len(b)):
		a += 1
	while a > 0:
		c += a
		a -= 1
	print(c + 10 * (int(b) % 10 - 1))


boring = []
for i in range(1, 10):
	for j in range(1, 5):
		boring.append(int(str(i) * j))
t = int(input())
ls = []
for i in range(t):
	num = int(input())
	ls.append(num)
for i in ls:
	ind = boring.index(i)
	tot = 0
	for j in boring[:ind + 1]:
		tot = tot + len(str(j))
	print(tot)


cases = []
for i in range(int(input(''))):
	cases.append(int(input('')))
for i in cases:
	count = 0
	for n in range(1, 10):
		for t in range(1, 5):
			count += t
			if i == int(str(n) * t):
				print(count)


t = int(input())
for i in range(t):
	n = 0
	c = 0
	m = 0
	x = int(input())
	r = x % 10
	n = (r - 1) * 10
	y = str(x)
	for k in y:
		c = c + 1
	m = c * (c + 1) // 2
	print(n + m)


for i in range(int(input())):
	s1 = ''
	n = int(input())
	r = n % 10
	s = (r - 1) * 10
	s1 = str(n)
	for i in range(1, len(s1) + 1):
		s = s + int(i)
	print(s)


def solve():
	num = int(input())
	count = 0
	for i in range(1, 10):
		k = i
		count += 1
		while True:
			if k == num:
				print(count)
				return
			k = int(str(k) + str(i))
			if k <= 9999:
				count += len(str(k))
			else:
				break
	print(count)
t = int(input())
for i in range(t):
	solve()


testcases = int(input())
for testcase in range(testcases):
	n = input()
	nn = int(n)
	lenchar = int(n[0])
	lenn = len(n)
	ans = 0
	for i in range(1, lenchar):
		ans += 10
	for i in range(1, lenn + 1):
		ans += i
	print(ans)


for _ in range(int(input())):
	otkr = int(input())
	k = 0
	for i in range(1, 10):
		if int(str(otkr)[0]) > i:
			k += 10
		elif int(str(otkr)[0]) == i:
			k += 1
			while otkr != i:
				i = int(str(i) + str(i)[0])
				k += len(str(i))
			print(k)


for _ in range(int(input())):
	n = int(input())
	s = []
	ans = 0
	for i in range(9):
		a = ''
		for j in range(4):
			a += str(i + 1)
			s.append(a)
	k = s.index(str(n))
	for i in range(k + 1):
		ans += len(s[i])
	print(ans)


x = int(input())
for j in range(x):
	a = input()
	count = 0
	count += (int(a[0]) - 1) * 10
	for i in range(1, len(a) + 1):
		count += i
	print(count)


for _ in range(int(input())):
	n = str(int(input()))
	b = len(n)
	c = 10 * (int(n[0]) - 1)
	for i in range(1, b + 1):
		c = c + i
	print(c)


t = int(input())
i = 0
while i < t:
	x = str(input())
	A = x[0]
	B = len(x)
	answer = (int(A) - 1) * 10 + int(B) * (int(B) + 1) // 2
	print(answer)
	i += 1


for _ in range(int(input())):
	n = input()
	s1 = (int(n[0]) - 1) * 10
	if len(n) == 1:
		print(s1 + 1)
	elif len(n) == 2:
		print(s1 + 3)
	elif len(n) == 3:
		print(s1 + 6)
	elif len(n) == 4:
		print(s1 + 10)


def cuenta_presionados(boring_numbers_, nvobuscar):
	presionados = 0
	for i in range(len(boring_numbers_)):
		if boring_numbers[i] != nvobuscar:
			numeritos = len(str(boring_numbers[i]))
			presionados += numeritos
		elif boring_numbers[i] == nvobuscar:
			numeritos = len(str(boring_numbers[i]))
			presionados += numeritos
			return presionados
	return f'EN TOTAL SE PRESIONARON: {presionados}'

def boring_numbers():
	contador = 0
	n = 1
	temp = 1
	boring_numbers = []
	while n != 9999:
		boring_numbers.append(n)
		while len(str(n)) != 4:
			n = int(str(n) + '' + str(temp))
			boring_numbers.append(n)
		if n != 9999:
			temp += 1
			n = temp
		else:
			boring_numbers.append(n)
			n = 9999
	return boring_numbers
casos = int(input())
buscar = []
boring_numbers = boring_numbers()
for i in range(casos):
	buscar.append(int(input()))
for j in buscar:
	print(cuenta_presionados(boring_numbers, j))


t = int(input())
for q in range(t):
	n = input()
	a = n[0]
	ans = 0
	if int(a) != 1:
		ans += (int(a) - 1) * 10
	c = len(n)
	ans += c * (c + 1) / 2
	print(int(ans))


from sys import stdin
a = [1, 3, 6, 10]
for _ in range(int(stdin.readline())):
	s = stdin.readline().rstrip()
	t = len(s) - 1
	c = int(s[0]) - 1
	print(c * 10 + a[t])


def solve():
	n = input()
	size = len(n)
	lst = [1, 3, 6, 10]
	ans = (int(n[0]) - 1) * 10
	no = int(str(1) * size) * int(n[0])
	if int(n) >= no:
		if size - 1 >= 0:
			ans += lst[size - 1]
	elif size - 2 >= 0:
		ans += lst[size - 2]
	print(ans)
	return
t = int(input())
while t != 0:
	solve()
	t -= 1


def driver():
	t = int(input())
	for i in range(t):
		solution()

def solution():
	a = input()
	l = len(a)
	print(10 * (int(a[0]) - 1) + l * (l + 1) // 2)
driver()


a = int(input())
b = []
for i in range(a):
	c = input()
	d = len(c)
	e = int(c[0])
	f = e * 10 - (10 - (d ** 2 + d) / 2)
	b.append(f)
for j in range(a):
	print(int(b[j]))


t = int(input())
for el in range(t):
	n = input()
	result = 0
	for x in range(1, 10):
		for y in range(1, 5):
			curr = str(x) * y
			if curr <= n:
				result += len(curr)
	print(result)


import sys
input = sys.stdin.readline
ins = lambda : input().rstrip()
ini = lambda : int(input().rstrip())
inm = lambda : map(int, input().rstrip().split())
inl = lambda : list(map(int, input().split()))
out = lambda x, s='\n': print(s.join(map(str, x)))
t = ini()
for _ in range(t):
	n = ini()
	a = [1, 3, 6, 10]
	print((n % 10 - 1) * 10 + a[len(str(n)) - 1])


boredNums = []
newBoredNums = []
g = 1
b = 1
for x in range(0, 10000):
	reversNum = [i for i in str(x)]
	a = reversNum[0]
	flag = False
	for z in range(1, len(reversNum)):
		if int(a) != int(reversNum[z]):
			flag = True
	if flag == False:
		boredNums.append(x)
while g <= 9:
	for j in range(0, len(boredNums)):
		if int(str(boredNums[j])[0]) == b:
			newBoredNums.append(int(boredNums[j]))
	b += 1
	g += 1
t = int(input())
k = 0
result = []
while k <= t - 1:
	v = int(input())
	arr = newBoredNums[:newBoredNums.index(v) + 1]
	res = 0
	for h in range(0, len(arr)):
		res += len(str(arr[h]))
	result.append(res)
	k += 1
for f in range(0, len(result)):
	print(result[f])


a = []
chars = [ch for ch in '123456789']
for i in range(len(chars)):
	for j in range(1, 5):
		a.append(chars[i] * j)
for _ in range(int(input())):
	s = input()
	inn = a.index(s)
	count = 0
	for i in range(inn + 1):
		count += len(a[i])
	print(count)


for qwert in range(int(input())):
	n = input()
	x = (int(n[0]) - 1) * 10
	y = len(n) * (len(n) + 1) / 2
	print(int(x + y))


import sys

def findNumDigits(num):
	if num == 1:
		return 1
	if num > 1:
		count = 0
		str_num = str(num)
		n = len(str_num)
		N = int(str_num[0])
		count = count + 10 * (N - 1)
		if n == 1:
			count = count + 1
		elif n == 2:
			count = count + 3
		elif n == 3:
			count = count + 6
		elif n == 4:
			count = count + 10
	return count
T = int(input())
for i in range(T):
	num = int(sys.stdin.readline().strip())
	print(findNumDigits(num))


t = int(input())
result = []
for i in range(t):
	total = 0
	first = 0
	n = str(input())
	first = int(n[0])
	int(n)
	total += sum(list(range(1, len(n) + 1))) + 10 * (first - 1)
	result.append(total)
for i in result:
	print(i)


t = int(input())
while t:
	n = int(input())
	x = n % 10
	c = 0
	while n:
		n = n // 10
		c += 1
	print((x - 1) * 10 + c * (c + 1) // 2)
	t -= 1


ll = []
for x in range(1, 10):
	for y in range(1, 5):
		ll.append(str(x) * y)
for x in range(int(input())):
	n = input()
	c = ll.index(n) + 1
	q = c // 4
	r = c % 4
	m = r * (r + 1) / 2
	print(int(q * 10) + int(m))


def program():
	num = int(input())
	total = 0
	for dig in range(1, 10):
		for siz in range(1, 5):
			total += siz
			n = int(str(dig) * siz)
			if n == num:
				return total
for i in range(int(input())):
	print(program())


N = int(input())
for i in range(N):
	Ans = 0
	A = input()
	if len(A) == 1:
		Ans += 1
	elif len(A) == 2:
		Ans += 3
	elif len(A) == 3:
		Ans += 6
	else:
		Ans += 10
	Ans += (int(A[0]) - 1) * 10
	print(Ans)


LENGHT = {1: 1, 2: 3, 3: 6, 4: 10}
list_of_numbers = list()
for i in range(int(input())):
	list_of_numbers.append(int(input()))
for i in list_of_numbers:
	result = (int(str(i)[0]) - 1) * 10 + LENGHT[len(str(i))]
	print(result)


t = int(input())
while t != 0:
	t = t - 1
	num = input()
	lenght = int(len(num))
	integer = int(num)
	initial = 10
	flist = [0, 1, 3, 6, 10]
	final = int(integer / 10 ** (lenght - 1))
	result = initial * (final - 1) + flist[lenght]
	print(result)


def fact(n):
	if n == 1:
		return 1
	else:
		return n + fact(n - 1)

def sol(n):
	l = len(str(n))
	d = n % 10
	return 10 * (d - 1) + fact(l)
t = int(input())
for _ in range(t):
	n = int(input())
	print(sol(n))


t = int(input())
for _ in range(t):
	s = input()
	print((int(s[0]) - 1) * 10 + len(s) * (len(s) + 1) // 2)


t = int(input())
for i in range(t):
	x = int(input())
	r = int(x % 10)
	q = len(str(x))
	s = 0
	if r > 1:
		if q == 1:
			s = 1 + (r - 1) * 10
		elif q == 2:
			s = 3 + (r - 1) * 10
		elif q == 3:
			s = 6 + (r - 1) * 10
		elif q == 4:
			s = r * 10
	elif r == 1:
		if q == 1:
			s = 1
		elif q == 2:
			s = 3
		elif q == 3:
			s = 6
		elif q == 4:
			s = 10
	print(s)


t = int(input())
potentials = []
n = 1
while n <= 10000:
	digits = [digit for digit in str(n)]
	if digits.count(digits[0]) == len(digits):
		potentials.append(str(n))
	n += 1
potentials.sort(key=lambda x: str(x[0]))
for caseNr in range(1, t + 1):
	n = int(input())
	num = 1
	counter = 0
	for thing in potentials:
		counter += len(thing)
		if int(thing) == n:
			break
	print(counter)


lst = ['1', '11', '111', '1111', '2', '22', '222', '2222', '3', '33', '333', '3333', '4', '44', '444', '4444', '5', '55', '555', '5555', '6', '66', '666', '6666', '7', '77', '777', '7777', '8', '88', '888', '8888', '9', '99', '999', '9999']
t = int(input())
for e in range(t):
	N = int(input())
	val = 0
	for i in lst:
		if N == int(i):
			break
		else:
			val = val + int(len(i))
	print(val + len(str(N)))


t = int(input())
N = []
for i in range(t):
	N.append(str(input()))

def add(b):
	x = 0
	for i in range(b + 1):
		x += i
	return x

def evaluate(i):
	a = i[0]
	b = len(i)
	return 10 * (int(a) - 1) + add(b)
for i in N:
	print(evaluate(i))


import sys

def main():
	t = Iint()
	for _ in range(t):
		s = Istr()
		c = s[0]
		l = len(s)
		ans = (int(c) - 1) * 10 + l * (l + 1) // 2
		print(ans)
en = enumerate
FIO = 10

def debug(*args, c=6):
	pass
	print('\x1b[3{}m'.format(c), *args, '\x1b[0m', file=sys.stderr)
BUFSIZE = 8 * 1024

def Istr():
	return input()

def Iint():
	return int(input())

def Ilist():
	return list(map(int, input().split()))

def Imap():
	return map(int, input().split())

def Plist(li, s=' '):
	print(s.join(map(str, li)))
if not FIO:
	if __name__ == '__main__':
		main()
		exit()
else:
	from io import BytesIO, IOBase
	import os

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))

def input():
	return sys.stdin.readline().rstrip('\r\n')
main()


t = int(input())
for i in range(t):
	n = list(input())
	c = 0
	x = int(n[0])
	c = (x % 10 - 1) * 10
	dig = 0
	if len(n) == 1:
		c += 1
	elif len(n) == 2:
		c += 3
	elif len(n) == 3:
		c += 6
	else:
		c += 10
	print(c)


from itertools import permutations
for _ in range(int(input())):
	n = int(input())
	a = []
	for i in range(1, 10):
		s = str(i)
		k = s
		a.append(int(k))
		while len(s) < 4:
			p = s + k
			a.append(int(p))
			s = p
	s = 0
	for i in range(len(a)):
		if a[i] == n:
			p = str(a[i])
			s += len(p)
			break
		else:
			p = str(a[i])
			s += len(p)
	print(s)


import sys
t = int(sys.stdin.readline())
ans_arr = []
for i in range(t):
	x = int(sys.stdin.readline())
	d = x % 10
	s = len(str(x))
	answer = str(10 * (d - 1) + s * (s + 1) // 2)
	ans_arr.append(answer)
print('\n'.join(ans_arr))


t = int(input())
for i in range(t):
	x = int(input())
	y = x
	n = x % 10
	c = 1
	fc = 0
	while y > 10:
		fc += c
		c += 1
		y = y // 10
	fc += c
	fc += (n - 1) * 10
	print(fc)


t = int(input())
for i in range(t):
	s = input()
	c = 10 * (int(s[0]) - 1)
	if len(s) == 4:
		print(c + 10)
	elif len(s) == 3:
		print(c + 6)
	elif len(s) == 2:
		print(c + 3)
	else:
		print(c + 1)


t = int(input())
for _ in range(t):
	n = int(input())
	(ans, num) = (0, 0)
	stop = False
	for i in range(1, 11):
		num = i
		arr = [0, 10 * i, 100 * i, 1000 * i]
		for j in arr:
			num += j
			ans += len(str(num))
			if num == n:
				stop = True
				break
		if stop:
			break
	print(ans)


def getDigits(n):
	ans = 0
	m = int(n[0])
	ans = (m - 1) * 10
	m = len(n)
	ans += m * (m + 1) / 2
	return int(ans)
t = int(input())
for i in range(t):
	n = input()
	val = getDigits(n)
	print(val)


t = int(input())
for test in range(t):
	n = input()
	ans = (int(n[-1]) - 1) * 10
	for i in range(len(n)):
		ans += i + 1
	print(ans)


t = int(input())
for _ in range(t):
	x = int(input())
	ans = 0
	first = int(str(x)[0])
	length = len(str(x))
	l = 10
	a = [1, 3, 6, 10]
	for i in range(first - 1):
		ans += l
	ans += a[length - 1]
	print(ans)


t = int(input())
for i in range(t):
	res = 0
	n = int(input())
	n = list(map(int, str(n)))
	res += 10 * (n[0] - 1) + len(n) * (len(n) + 1) // 2
	print(res)


l = []
for i in range(1, 10):
	k = str(i)
	for j in range(0, 4):
		l.append(str(i))
		i = str(i) + k

def cout(x):
	c = 0
	for i in range(0, len(l)):
		c = c + len(l[i])
		if str(x) == l[i]:
			return c
t = input()
t1 = []
for i in range(0, int(t)):
	x = int(input())
	t1.append(x)
for i in t1:
	if str(i) in l:
		print(cout(i))


t = int(input())
for i in range(t):
	r = int(input())
	f = 0
	s = 0
	for i in range(1, 10):
		for j in [1, 11, 111, 1111]:
			x = i * j
			if f == 0:
				s += len(str(x))
			if x == r:
				f = 1
	print(s)


test = int(input())
counter1 = 0
list = []
while counter1 < test:
	resident = int(input())
	counter2 = 1
	answer = 0
	while resident % 10 > counter2:
		answer += 10
		counter2 += 1
	answer += 1
	if resident > 10:
		answer += 2
	if resident > 100:
		answer += 3
	if resident > 1000:
		answer += 4
	list.append(answer)
	counter1 += 1
counter1 = 0
while test > counter1:
	print(list[counter1])
	counter1 += 1


for _ in range(int(input())):
	a = int(input())
	c = 0
	flag = 0
	d = ''
	for i in range(1, 10):
		for j in range(1, 5):
			d = str(i) * j
			c += len(d)
			if int(d) == a:
				print(c)
				break


for t in range(int(input())):
	x = int(input())
	dg = x % 10
	nod = 0
	while x > 0:
		nod += 1
		x = x // 10
	ans = (dg - 1) * 10 + nod * (nod + 1) // 2
	print(ans)


s = ['1', '11', '111', '1111', '2', '22', '222', '2222', '3', '33', '333', '3333', '4', '44', '444', '4444', '5', '55', '555', '5555', '6', '66', '666', '6666', '7', '77', '777', '7777', '8', '88', '888', '8888', '9', '99', '999', '9999']
rslt = []
d = 0
c = 0
for i in range(36):
	d += 1
	c += d
	rslt.append(c)
	if d == 4:
		d = 0
n = int(input())
for x in range(n):
	a = str(input())
	print(rslt[s.index(a)])


from __future__ import division, print_function
import os, sys
from io import BytesIO, IOBase
if sys.version_info[0] < 3:
	from __builtin__ import xrange as range
	from future_builtins import ascii, filter, hex, map, oct, zip

def ii():
	return int(input())

def si():
	return input()

def mi():
	return map(int, input().strip().split(' '))

def msi():
	return map(str, input().strip().split(' '))

def li():
	return list(mi())

def dmain():
	sys.setrecursionlimit(1000000)
	threading.stack_size(1024000)
	thread = threading.Thread(target=main)
	thread.start()
import sys
input = sys.stdin.readline
scanner = lambda : int(input())
string = lambda : input().rstrip()
get_list = lambda : list(read())
read = lambda : map(int, input().split())
get_float = lambda : map(float, input().split())

def ceil(x):
	if x != int(x):
		x = int(x) + 1
	return x

def factorial(x, m):
	val = 1
	while x > 0:
		val = val * x % m
		x -= 1
	return val

def fact(x):
	val = 1
	while x > 0:
		val *= x
		x -= 1
	return val

def swaparr(arr, a, b):
	temp = arr[a]
	arr[a] = arr[b]
	arr[b] = temp

def gcd(a, b):
	if b == 0:
		return a
	return gcd(b, a % b)

def lcm(a, b):
	return a * b // math.gcd(a, b)

def is_integer(n):
	return math.ceil(n) == math.floor(n)

def nCr(n, k):
	if k > n:
		return 0
	if k > n - k:
		k = n - k
	res = 1
	for i in range(k):
		res = res * (n - i)
		res = res / (i + 1)
	return int(res)

def primefs(n):
	primes = {}
	while n % 2 == 0 and n > 0:
		primes[2] = primes.get(2, 0) + 1
		n = n // 2
	for i in range(3, int(n ** 0.5) + 2, 2):
		while n % i == 0 and n > 0:
			primes[i] = primes.get(i, 0) + 1
			n = n // i
	if n > 2:
		primes[n] = primes.get(n, 0) + 1
	return primes

def power(x, y, p):
	if y == 0:
		return 1
	res = 1
	x = x % p
	if x == 0:
		return 0
	while y > 0:
		if y & 1 == 1:
			res = res * x % p
		y = y >> 1
		x = x * x % p
	return res

def swap(a, b):
	temp = a
	a = b
	b = temp
	return (a, b)

def find(x, link):
	p = x
	while p != link[p]:
		p = link[p]
	while x != p:
		nex = link[x]
		link[x] = p
		x = nex
	return p

def union(x, y, link, size):
	x = find(x, link)
	y = find(y, link)
	if size[x] < size[y]:
		(x, y) = swap(x, y)
	if x != y:
		size[x] += size[y]
		link[y] = x

def sieve(n):
	prime = [True for i in range(n + 1)]
	(prime[0], prime[1]) = (False, False)
	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

def phi(n):
	result = n
	p = 2
	while p * p <= n:
		if n % p == 0:
			while n % p == 0:
				n = n // p
			result = result * (1.0 - 1.0 / float(p))
		p = p + 1
	if n > 1:
		result = result * (1.0 - 1.0 / float(n))
	return int(result)

def is_prime(n):
	if n == 0:
		return False
	if n == 1:
		return True
	for i in range(2, int(n ** (1 / 2)) + 1):
		if not n % i:
			return False
	return True

def next_prime(n, primes):
	while primes[n] != True:
		n += 1
	return n
MAXN = int(100000.0 + 5)

def spf_sieve():
	spf[1] = 1
	for i in range(2, MAXN):
		spf[i] = i
	for i in range(4, MAXN, 2):
		spf[i] = 2
	for i in range(3, ceil(MAXN ** 0.5), 2):
		if spf[i] == i:
			for j in range(i * i, MAXN, i):
				if spf[j] == j:
					spf[j] = i
spf = [0 for i in range(MAXN)]

def factoriazation(x):
	res = []
	for i in range(2, int(x ** 0.5) + 1):
		while x % i == 0:
			res.append(i)
			x //= i
	if x != 1:
		res.append(x)
	return res

def factors(n):
	res = []
	for i in range(1, int(n ** 0.5) + 1):
		if n % i == 0:
			res.append(i)
			res.append(n // i)
	return list(set(res))

def int_array():
	return list(map(int, input().strip().split()))

def float_array():
	return list(map(float, input().strip().split()))

def str_array():
	return input().strip().split()

def binary_search(low, high, w, h, n):
	while low < high:
		mid = low + (high - low) // 2
		if check(mid, w, h, n):
			low = mid + 1
		else:
			high = mid
	return low

def check(moves, n):
	val = (moves + 1) // 2
	rem = moves - val
	sol = (val + 1) * (rem + 1)
	return sol < n

def sortSecond(val):
	return val[1]
MOD = int(1000000000.0) + 7
CMOD = 998244353
INF = float('inf')
NINF = -float('inf')
alphs = 'abcdefghijklmnopqrstuvwxyz'
from itertools import permutations
import math
import bisect as bis
import random
import sys
import collections as collect
import functools as fnt
from decimal import Decimal

def solve():
	x = scanner()
	val = 10
	num = int(str(x)[0])
	ans = val * (num - 1)
	n = len(str(x))
	ans += n * (n + 1) // 2
	print(ans)
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')

def print(*args, **kwargs):
	(sep, file) = (kwargs.pop('sep', ' '), kwargs.pop('file', sys.stdout))
	at_start = True
	for x in args:
		if not at_start:
			file.write(sep)
		file.write(str(x))
		at_start = False
	file.write(kwargs.pop('end', '\n'))
	if kwargs.pop('flush', False):
		file.flush()
if sys.version_info[0] < 3:
	(sys.stdin, sys.stdout) = (FastIO(sys.stdin), FastIO(sys.stdout))
else:
	(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
input = lambda : sys.stdin.readline().rstrip('\r\n')
t = scanner()
for i in range(t):
	solve()


import math
from collections import Counter, defaultdict, deque

def f(n):
	num = int(n) % 10
	l = len(n)
	if l == 1:
		ans = 1
	if l == 2:
		ans = 3
	if l == 3:
		ans = 6
	if l == 4:
		ans = 10
	return (num - 1) * 10 + ans
t = int(input())
result = []
for i in range(t):
	n = input()
	result.append(f(n))
for i in range(t):
	print(result[i])


import sys, math
from collections import deque, defaultdict
import operator as op
from functools import reduce
sys.setrecursionlimit(10 ** 6)
I = sys.stdin.readline

def ii():
	return int(I().strip())

def li():
	return list(map(int, I().strip().split()))

def mi():
	return map(int, I().strip().split())

def ncr(n, r):
	r = min(r, n - r)
	numer = reduce(op.mul, range(n, n - r, -1), 1)
	denom = reduce(op.mul, range(1, r + 1), 1)
	return numer // denom

def gcd(x, y):
	while y:
		(x, y) = (y, x % y)
	return x

def valid(row, col, rows, cols, rcross, lcross):
	return rows[row] == 0 and cols[col] == 0 and (rcross[col + row] == 0) and (lcross[col - row] == 0)

def main():
	ans = ''
	for _ in range(ii()):
		n = ii()
		i = 1
		flag = 0
		cnt = 0
		while i <= 9:
			tmp = 0
			for j in range(4):
				tmp = tmp * 10 + i
				cnt += len(str(tmp))
				if tmp == n:
					flag = 1
					break
			if flag:
				break
			i += 1
		ans += str(cnt) + '\n'
	print(ans)
main()


import sys
import math
from math import *
from collections import Counter, defaultdict, deque
from bisect import bisect
lip = lambda : list(map(int, input().split()))
ip = lambda : int(input())
sip = lambda : input().split()
mod = 10 ** 9 + 7

def main():
	s = input()
	val = (int(s[0]) - 1) * 10 + len(s) * (len(s) + 1) // 2
	print(val)
for i in range(ip()):
	main()


n = int(input())
while n != 0:
	x = input()
	r = 0
	sum = 0
	for i in range(1, 10):
		apt_no = ''
		for j in range(1, 5):
			apt_no = apt_no.ljust(j, str(i))
			sum = sum + int(len(apt_no))
			if x == apt_no:
				r = 1
				break
		if r == 1:
			break
	print(sum)
	n -= 1


def get_answer(num):
	sum = 0
	name = ''
	for j in range(1, 11):
		name = ''
		for i in range(1, 5):
			name += str(j)
			sum += len(name)
			if name == num:
				return sum
num_of_tests = int(input())
for i in range(0, num_of_tests):
	answer = input()
	print(get_answer(answer))


from collections import Counter
import io, os, math
input = io.BytesIO(os.read(0, os.fstat(0).st_size)).readline
rr = lambda : input()
rri = lambda : int(input())
rrm = lambda : list(map(int, input().split()))
INF = float('inf')

def solve(X):
	keypresses = 0
	s = str(X)
	leng = len(s)
	end = False
	for digit in range(1, 10):
		arr = []
		for times in range(1, 5):
			arr.append(str(digit))
			if int(''.join(arr)) == X:
				keypresses += len(arr)
				end = True
				break
			else:
				keypresses += len(arr)
		if end:
			break
	return keypresses
t = rri()
for _ in range(t):
	X = rri()
	print(solve(X))


t = int(input())
lst = [0] * t
for i in range(t):
	a = int(input())
	c = len(str(a))
	b = (a - 1) % 10 * 10
	b += c * (c + 1) // 2
	lst[i] = b
for i in lst:
	print(i)


def d(n):
	w = [1, 11, 111, 1111, 2, 22, 222, 2222, 3, 33, 333, 3333, 4, 44, 444, 4444, 5, 55, 555, 5555, 6, 66, 666, 6666, 7, 77, 777, 7777, 8, 88, 888, 8888, 9, 99, 999, 9999]
	q = [1, 2, 3, 4, 1, 2, 3, 4, 1, 2, 3, 4, 1, 2, 3, 4, 1, 2, 3, 4, 1, 2, 3, 4, 1, 2, 3, 4, 1, 2, 3, 4, 1, 2, 3, 4]
	for i in range(len(w)):
		if w[i] == n:
			return sum(q[:i + 1])
for i in range(int(input())):
	n = int(input())
	print(d(n))


for _ in range(int(input())):
	n = int(input())
	rem = n % 10
	dig = 0
	while n != 0:
		n //= 10
		dig += 1
	ans = (rem - 1) * 10 + dig * (dig + 1) // 2
	print(ans)


def countDigit(n):
	count = 0
	while n != 0:
		n //= 10
		count += 1
	return count
t = int(input())
l = [1, 2, 3, 4]
fin = [0] * t
i = 0
if t <= 36 and t >= 1:
	while i < t:
		x = int(input())
		if x >= 1 and x <= 9999:
			nd = countDigit(x)
			v = x % 10
			fin[i] = 10 * (v - 1)
			for j in range(nd):
				fin[i] = fin[i] + l[j]
			i = i + 1
for i in fin:
	print(i)


t = int(input())
for i in range(t):
	s = input()
	n = len(s)
	x = set(s)
	d = list(x)
	print(10 * (int(d[0]) - 1) + n * (n + 1) // 2)


for t in [0] * int(input()):
	ac = input()
	l = len(ac)
	fd = int(ac[0])
	s = (fd - 1) * 10
	s += l * (l + 1) // 2
	print(s)


import math

def solve(x):
	x1 = x % 10
	result = 10 * (x1 - 1)
	length = len(str(x))
	if length == 1:
		result = result + 1
	elif length == 2:
		result = result + 3
	elif length == 3:
		result = result + 6
	elif length == 4:
		result = result + 10
	return result
t = int(input())
for i in range(t):
	number = int(input())
	print(solve(number))


t = int(input())
k = 1
while t > 0:
	t = t - 1
	n = input()
	leng = len(n)
	if leng == 1:
		var = 1
	elif leng == 2:
		var = 3
	elif leng == 3:
		var = 6
	elif leng == 4:
		var = 10
	count = 10 * (int(n[0]) - 1) + var
	print(count)


def sum(n):
	if n == 1:
		return 1
	else:
		return n + sum(n - 1)
t = int(input())
for i in range(t):
	x = int(input())
	d = x % 10
	prev = (d - 1) * 10
	n = len(str(x))
	ans = prev + sum(n)
	print(ans)


for _ in range(int(input())):
	n = input()
	(temp, l) = (int(n[0]), len(n))
	ans = 10 * (temp - 1) + l * (l + 1) // 2
	print(ans)


for _ in range(int(input())):
	n = list(input())
	out = (int(n[0]) - 1) * 10
	l = len(n)
	out += l * (l + 1) // 2
	print(out)


n = int(input())
a = []
for i in range(n):
	x = int(input())
	y = (int(str(x)[0]) - 1) * 10
	z = 0
	for i in range(len(str(x))):
		z += i + 1
	a.append(z + y)
for i in a:
	print(i)


arr = []
for i in range(1, 10):
	for j in range(4):
		arr.append(str(i) * (j + 1))
for _ in range(int(input())):
	n = int(input())
	ans = 0
	for i in range(36):
		if int(str(n)[0]) < int(arr[i][0]):
			break
		if str(n)[0] != arr[i][0]:
			ans += len(arr[i])
		elif n >= int(arr[i]):
			ans += len(arr[i])
		else:
			break
	print(ans)


t = int(input())
l = [1, 11, 111, 1111, 2, 22, 222, 2222, 3, 33, 333, 3333, 4, 44, 444, 4444, 5, 55, 555, 5555, 6, 66, 666, 6666, 7, 77, 777, 7777, 8, 88, 888, 8888, 9, 99, 999, 9999]
for _ in range(t):
	n = int(input())
	x = l.index(n) + 1
	te = x % 4
	te1 = x // 4
	ans = 10 * te1 + te * (te + 1) // 2
	print(ans)


def solve(n):
	a = [1, 11, 111, 1111, 2, 22, 222, 2222, 3, 33, 333, 3333, 4, 44, 444, 4444, 5, 55, 555, 5555, 6, 66, 666, 6666, 7, 77, 777, 7777, 8, 88, 888, 8888, 9, 99, 999, 9999]
	for i in range(len(a)):
		if i < len(a) and a[i] == n:
			return sum((len(str(x)) for x in a[:i + 1]))
t = int(input())
while t:
	n = int(input())
	print(solve(n))
	t -= 1


t = int(input())
for i in range(t):
	n = int(input())
	sum = 0
	k = n % 10
	if k != 1:
		sum += 10 * (k - 1)
	if len(str(n)) == 1:
		sum += 1
	elif len(str(n)) == 2:
		sum += 3
	elif len(str(n)) == 3:
		sum += 6
	else:
		sum += 10
	print(sum)


t = int(input())
for i in range(t):
	n = input()
	r = int(n[0])
	l = len(n)
	ans = [1, 3, 6, 10]
	print(10 * (r - 1) + ans[l - 1])


t = int(input())
for i in range(t):
	s = input()
	l = len(s)
	c = 0
	n = int(s[0])
	for i in range(n - 1):
		c += 10
	for i in range(l):
		c += i + 1
	print(c)


t = int(input())
for _ in range(t):
	n = int(input())
	k = n % 10
	ans = (k - 1) * 10
	s = str(n)
	p = len(s)
	d = p * (p + 1)
	d = d // 2
	ans = ans + d
	print(ans)


t = int(input())
for i in range(0, t):
	x = int(input())
	sum1 = 0
	y = str(x)
	for j in y:
		sum1 += int(j)
	ans = 10 * (int(y[0]) - 1)
	for j in range(1, 5):
		if int(y[0]) * j <= sum1:
			ans += j
	print(int(ans))


from math import *
sInt = lambda : int(input())
mInt = lambda : map(int, input().split())
lInt = lambda : list(map(int, input().split()))
t = sInt()
for _ in range(t):
	x = input()
	ans = 0
	l = len(x)
	d = int(x) // 10 ** (l - 1)
	ans += (d - 1) * 10
	c = x.count(x[0])
	while c > 0:
		ans += c
		c -= 1
	print(ans)


for t in range(int(input())):
	num = input()
	ans = 0
	if num == '10000':
		print(90)
	else:
		ans += (int(num[0]) - 1) * 10
		if len(num) == 1:
			ans += 1
		elif len(num) == 2:
			ans += 3
		elif len(num) == 3:
			ans += 6
		else:
			ans += 10
		print(ans)


for _ in range(int(input())):
	n = int(input())
	l = list(str(n))
	x = int(l[0])
	ans = 10 * (x - 1) + len(l) * (len(l) + 1) // 2
	print(ans)


for case in range(int(input())):
	baprt = input()
	ln = len(baprt)
	st = int(baprt[0])
	ans = sum(range(1, ln + 1)) + (st - 1) * 10
	print(ans)


testcases = int(input())
for x in range(testcases):
	a = 1
	b = 0
	number = [str(i) for i in input()]
	lnum = number
	while a < int(number[0]):
		a += 1
		b += 10
	while len(lnum) != 0:
		b += len(lnum)
		lnum.pop()
	print(b)


for _ in range(int(input())):

	def factorial(a):
		l = 0
		for i in range(a):
			l += i + 1
		return l
	x = input()
	print(10 * (int(x[0]) - 1) + factorial(len(x)))


t = int(input())
for i in range(t):
	totalLen = int(input())
	factor = str(totalLen)[0]
	count = len(str(totalLen))
	totalAns = (int(factor) - 1) * 10
	if count == 1:
		totalAns += 1
	elif count == 2:
		totalAns += 3
	elif count == 3:
		totalAns += 6
	elif count == 4:
		totalAns += 10
	print(totalAns)


for i in range(int(input())):
	x = input()
	digit = int(x[0])
	ln1 = len(x)
	print(int(10 * (digit - 1) + ln1 * (ln1 + 1) / 2))


nimo = int(input())
abcimo = [1, 2, 3, 4]
for ximo in range(nimo):
	ansimo = 0
	aimo = 0
	nimo = int(input())
	countimo = 0
	aimo = int(nimo % 10)
	bimo = (aimo - 1) * 10
	while nimo > 0:
		countimo = countimo + 1
		nimo = nimo // 10
	for iimo in range(countimo):
		ansimo = ansimo + abcimo[iimo]
	print(ansimo + bimo)


for t in range(int(input())):
	n = int(input())
	if n < 10:
		print(10 * (n - 1) + 1)
	elif n % 1111 == 0:
		z = n % 10
		print(z * 10)
	elif n % 111 == 0:
		z = n % 10
		print((z - 1) * 10 + 6)
	elif n % 11 == 0:
		z = n % 10
		print((z - 1) * 10 + 3)


def ans(n):
	w = n % 10
	x = str(n)
	z = len(x)
	ans = (w - 1) * 10
	if z == 1:
		ans += 1
	elif z == 2:
		ans += 3
	elif z == 3:
		ans += 6
	else:
		ans += 10
	return ans
m = int(input())
for j in range(m):
	n = int(input())
	print(ans(n))


l = []
for i in range(1, 10):
	s = str(i)
	for j in range(0, 4):
		l.append(s)
		s += str(i)
t = int(input())
while t > 0:
	t -= 1
	n = str(input())
	ans = 0
	for i in l:
		ans += len(i)
		if i == n:
			break
	print(ans)


N = int(input())
m = [1, 3, 6, 10]
for i in range(N):
	n = input()
	res = (int(n[0]) - 1) * 10
	res += m[len(n) - 1]
	print(res)


print('\n'.join([str((int(i[0]) - 1) * 10 + len(i) * (len(i) + 1) // 2) for i in [input() for i in range(int(input()))]]))


t = int(input())
for i in range(t):
	x = input()
	a = x[0]
	s = 0
	if int(a) == 1:
		for i in range(1, len(x) + 1):
			s += i
		print(s)
	else:
		b = int(a) - 1
		for i in range(b):
			s += 10
		for i in range(1, len(x) + 1):
			s += i
		print(s)


n = int(input())
answers = []
for i in range(n):
	number = int(input())
	leng = len(str(number))
	if number % 10 == 1:
		answers.append(int((1 + leng) / 2 * leng))
	else:
		answers.append(int((number % 10 - 1) * 10 + (1 + leng) / 2 * leng))
for answer in answers:
	print(answer)


li = [i for i in range(1, 11)]

def boringapartments(x):
	count = 0
	for i in range(1, int(x[0])):
		count += 10
	var = len(x)
	if var == 1:
		count += 1
	elif var == 2:
		count += 3
	elif var == 3:
		count += 6
	else:
		count += 10
	print(count)
tc = int(input())
for i in range(tc):
	x = input()
	boringapartments(x)


t = int(input())
if 1 <= t <= 36:
	for i in range(t):
		x = str(input())
		if 1 <= int(x) <= 9999:
			x = list(x)
			total = int(x[0]) * 10
			count = len(x)
			neg = 0
			for i in range(count + 1, 5):
				neg += i
			ans = total - neg
			print(ans)


t = int(input())
for _ in range(t):
	stop_apt = input()
	numb = ord(stop_apt[0]) - ord('0')
	total = (numb - 1) * 10
	l = len(stop_apt)
	total += int(l * (l + 1) / 2)
	print(total)


d = {0: {'': 0}}
last = ''
for i in range(1, 10):
	st = str(i)
	while len(st) < 5:
		if d.get(i):
			d[i][st] = len(st) + d[i][st[:-1]]
		else:
			d[i] = {st: 1 + d[i - 1][last]}
		st += str(i)
	last = st[:-1]
t = int(input())
for _ in range(t):
	s = int(input())
	st = str(s)
	print(d[int(st[0])][st])


a = int(input())
for i in range(a):
	b = input()
	ans = 0
	dict1 = {'1': 1, '2': 3, '3': 6, '4': 10}
	ans = (int(b[0]) - 1) * 10 + dict1[str(len(b))]
	print(ans)


for i in range(int(input())):
	sum = 0
	n = input()
	sum += (int(n[0]) - 1) * 10
	for j in range(1, len(n) + 1):
		sum += j
	print(sum)


import sys
t = int(input().strip())
for a0 in range(t):
	n = int(input())
	l = [1, 11, 111, 1111, 2, 22, 222, 2222, 3, 33, 333, 3333, 4, 44, 444, 4444, 5, 55, 555, 5555, 6, 66, 666, 6666, 7, 77, 777, 7777, 8, 88, 888, 8888, 9, 99, 999, 9999]
	count = 0
	for i in l:
		count += 1
		if i == n:
			break
	ans = 0
	if count % 4 == 0:
		ans += 10
	if count % 4 == 1:
		ans += 1
	if count % 4 == 2:
		ans += 3
	if count % 4 == 3:
		ans += 6
	if (count - 1) // 4 == 0:
		ans += 0
	if (count - 1) // 4 == 1:
		ans += 10
	if (count - 1) // 4 == 2:
		ans += 20
	if (count - 1) // 4 == 3:
		ans += 30
	if (count - 1) // 4 == 4:
		ans += 40
	if (count - 1) // 4 == 5:
		ans += 50
	if (count - 1) // 4 == 6:
		ans += 60
	if (count - 1) // 4 == 7:
		ans += 70
	if (count - 1) // 4 == 8:
		ans += 80
	print(ans)


for z in range(int(input())):
	n = input()
	b = len(n)
	a = int(n[0])
	print(int((a - 1) * 10 + b * (b + 1) / 2))


n = int(input())
while n:
	x = int(input())
	y = str(x)
	length = len(y)
	number = 0
	for i in range(1, length + 1):
		number += i
	num = (int(y[0]) - 1) * 10 + number
	n -= 1
	print(num)


n = int(input())
for i in range(n):
	x = input()
	n = len(x)
	ans = n * (n + 1) // 2 + (int(x[0]) - 1) * 10
	print(ans)


def main():
	t = int(input())
	for _ in range(t):
		x = int(input())
		n = (int(str(x)[0]) - 1) * 4 + len(str(x))
		print(n // 4 * 10 + [0, 1, 3, 6][n % 4])
main()


t = int(input())
for i in range(t):
	st = str(input().strip())
	r = int(st[0])
	n = len(st)
	cost = (r - 1) * 10
	cost += int(n * (n + 1) / 2)
	print(cost)


from sys import stdin, stdout
import math, sys, heapq
from itertools import permutations, combinations
from collections import defaultdict, deque, OrderedDict
from os import path
import random
import bisect as bi

def yes():
	print('YES')

def no():
	print('NO')
if path.exists('input.txt'):
	sys.stdin = open('input.txt', 'r')
	sys.stdout = open('output.txt', 'w')

	def I():
		return int(input())

	def In():
		return map(int, input().split())
else:

	def I():
		return int(stdin.readline())

	def In():
		return map(int, stdin.readline().split())

def dict(a):
	d = {}
	for x in a:
		if d.get(x, -1) != -1:
			d[x] += 1
		else:
			d[x] = 1
	return d

def find_gt(a, x):
	i = bi.bisect_left(a, x)
	if i != len(a):
		return i
	else:
		return -1

def main():
	try:
		n = I()
		t = str(n)
		z = len(t)
		ans = 0
		if t[0] != '1':
			ans += 10 * (int(t[0]) - 1)
		ans += z * (z + 1) // 2
		print(ans)
	except:
		pass
M = 998244353
P = 1000000007
for _ in range(I()):
	main()


t = int(input())
while t > 0:
	t = t - 1
	n = input()
	val = (int(n[0]) - 1) * 10 + len(n) * (len(n) + 1) // 2
	print(val)


for _ in range(int(input())):
	n = input()
	k = int(n[0])
	p = 10 * (k - 1)
	z = len(n)
	p += z * (z + 1) // 2
	print(p)


t = int(input())
while t:
	t -= 1
	num = int(input())
	ans = 0
	it = num % 10
	ans += 10 * (it - 1)
	if num // 1000:
		ans += 10
	elif num // 100:
		ans += 6
	elif num // 10:
		ans += 3
	else:
		ans += 1
	print(ans)


r = []
for t in [0] * int(input()):
	ac = input()
	l = len(ac)
	fd = int(ac[0])
	s = 0
	if fd > 1:
		s += (fd - 1) * 10
		s += l * (l + 1) // 2
	else:
		s += l * (l + 1) // 2
	r.append(s)
for e in r:
	print(e)


def how_many_digits(x):
	digits = (int(x[0]) - 1) * 10
	for i in range(1, len(x) + 1):
		digits += i
	return digits
t = int(input())
for i in range(t):
	x = input()
	print(how_many_digits(x))


t = int(input())
for z in range(t):
	x = input()
	num = int(x[0])
	n = len(x)
	res = (num - 1) * 10 + n * (n + 1) // 2
	print(res)


I = input

def calc(last):
	n = [str(i) * k for i in range(1, 10) for k in range(1, 5)]
	iter = ''
	for i in '123456789':
		for j in n:
			if all([i == l for l in j]):
				if int(j) > int(last) and all([last[0] == h for h in j]):
					break
				iter += j
		if all([i == k for k in last]):
			break
	print(len(iter))

def main():
	n = I()
	for i in range(int(n)):
		calc(I())
main()


t = int(input())
a = []
for i in range(t):
	S = 0
	x = int(input())
	Q = '1'
	p = '1'
	while int(Q) != x:
		S += len(Q)
		Q = Q + p
		if len(Q) >= 5:
			p = str(int(p) + 1)
			Q = p
	S += len(Q)
	a.append(S)
for i in range(len(a)):
	print(a[i])


number_of_test_cases = int(input())
starting_digit = 1

def calculateSum(length):
	return length * (length + 1) // 2
for i in range(number_of_test_cases):
	answer = 0
	apartment_answered = input()
	digit = calculateSum(len(apartment_answered))
	last_digit = int(apartment_answered) % 10
	if last_digit != 1:
		answer += (last_digit - 1) * calculateSum(4) + digit
	else:
		answer += digit
	print(answer)


for _ in range(int(input())):
	a = [1, 3, 6, 10]
	n = input()
	z = int(n[0])
	print((z - 1) * 10 + a[len(n) - 1])


def solve():
	t = int(input())
	length = len(str(t))
	first = int(str(t)[0])
	c = 0
	for i in range(first):
		if i + 1 != first:
			c += 10
		else:
			for i in range(1, length + 1):
				c += i
	print(c)
N = int(input())
for _ in range(N):
	solve()


t = int(input())
for i in range(t):
	x = int(input())
	k1 = 10 * (x % 10 - 1)
	c = 0
	while x > 0:
		if x == 0:
			c += 1
		c += 1
		x = x // 10
	k2 = 0
	for j in range(c + 1):
		k2 += j
	print(k1 + k2)


t = int(input())
for _ in range(t):
	n = input()
	num = n[0]
	ans = 0
	ans = (int(num) - 1) * 10
	count = len(n)
	for i in range(1, count + 1):
		ans += i
	print(ans)


quant = int(input())
for i in range(0, quant):
	count = int(input())
	order = count % 10 - 1
	countOfCounts = len(str(count))
	if countOfCounts == 1:
		print(order * 10 + 1)
	elif countOfCounts == 2:
		print(order * 10 + 3)
	elif countOfCounts == 3:
		print(order * 10 + 6)
	else:
		print(order * 10 + 10)


for t in range(int(input())):
	x = input()
	outs = []
	for i in range(1, 10):
		for j in range(1, 5):
			outs.append(str(i) * j)
	count = 0
	for i in outs:
		if i == x:
			count += len(i)
			break
		else:
			count += len(i)
	print(count)


a = [1, 11, 111, 1111, 2, 22, 222, 2222, 3, 33, 333, 3333, 4, 44, 444, 4444, 5, 55, 555, 5555, 6, 66, 666, 6666, 7, 77, 777, 7777, 8, 88, 888, 8888, 9, 99, 999, 9999]
t = int(input())
s = 0
for i in range(t):
	x = int(input())
	for j in a:
		if j != x:
			if j % 10 != 0:
				s += 1
			if j // 10 % 10 != 0:
				s += 1
			if j // 100 % 10 != 0:
				s += 1
			if j // 1000 != 0:
				s += 1
		if j == x:
			if j % 10 != 0:
				s += 1
			if j // 10 % 10 != 0:
				s += 1
			if j // 100 % 10 != 0:
				s += 1
			if j // 1000 != 0:
				s += 1
			break
	print(s)
	s = 0


t = int(input())
while t > 0 and t < 37:
	for i in range(t):
		x = list(input())
		n = len(x)
		print(int((int(x[0]) - 1) * 10 + n * (n + 1) / 2))
	break


from os import path
import sys
from heapq import heappush, heappop
from functools import cmp_to_key as ctk
from collections import deque, defaultdict as dd
from bisect import bisect, bisect_left, bisect_right, insort, insort_left, insort_right
from itertools import permutations
from datetime import datetime
from math import ceil, sqrt, log, gcd

def ii():
	return int(input())

def si():
	return input().rstrip()

def mi():
	return list(map(int, input().split()))

def li():
	return list(mi())
abc = 'abcdefghijklmnopqrstuvwxyz'
mod = 1000000007
inf = float('inf')
vow = ['a', 'e', 'i', 'o', 'u']
(dx, dy) = ([-1, 1, 0, 0], [0, 0, 1, -1])

def bo(i):
	return ord(i) - ord('a')
file = 1

def solve():
	for _ in range(ii()):
		s = si()
		x = [1, 3, 6, 10]
		n = len(s)
		x1 = int(s[0])
		print(10 * (x1 - 1) + x[n - 1])

def __starting_point():
	if file:
		if path.exists('input.txt'):
			sys.stdin = open('input.txt', 'r')
			sys.stdout = open('output.txt', 'w')
		else:
			input = sys.stdin.readline
	solve()
__starting_point()


for _ in range(int(input())):
	s = input().strip()
	ans = (int(s[0]) - 1) * 10 + len(s) * (len(s) + 1) // 2
	print(ans)


for _ in range(int(input())):
	n = int(input())
	st = str(n)
	a = st[0]
	a = int(a)
	if a == 1:
		if len(st) == 1:
			print(1)
		elif len(st) == 2:
			print(3)
		elif len(st) == 3:
			print(6)
		else:
			print(10)
	else:
		s = 0
		for i in range(1, a):
			s = s + 10
		if len(st) == 1:
			s = s + 1
		elif len(st) == 2:
			s = s + 3
		elif len(st) == 3:
			s = s + 6
		else:
			s = s + 10
		print(s)


p = int(input())
ar = [1, 3, 6, 10]
for _ in range(p):
	x = int(input())
	print(10 * (int(str(x)[0:1]) - 1) + ar[int(len(str(x))) - 1])


def count(x):
	k = 0
	num = 1
	while num < 10000:
		size = len(str(num))
		k += size
		if num == x:
			return k
		if size < 4:
			num += num % 10 * 10 ** size
		else:
			num = num % 10 + 1
for i in range(int(input())):
	print(count(int(input())))


import sys
input = sys.stdin.readline
L = [0]
for i in range(1, 10):
	L.append(i)
	L.append(i * 10 + i)
	L.append(i * 100 + i * 10 + i)
	L.append(i * 1000 + i * 100 + i * 10 + i)
ANS = [0]
for i in range(len(L)):
	if i % 4 == 0:
		ANS.append(ANS[-1] + 1)
	elif i % 4 == 1:
		ANS.append(ANS[-1] + 2)
	elif i % 4 == 2:
		ANS.append(ANS[-1] + 3)
	elif i % 4 == 3:
		ANS.append(ANS[-1] + 4)
t = int(input())
for tests in range(t):
	x = int(input())
	a = L.index(x)
	print(ANS[a])


def num(n):
	x = n
	count = 0
	while x >= 1:
		x = x // 10
		count += 1
	return count
t = int(input())
for i in range(t):
	n = int(input())
	k = 0
	for i in range(1, num(n) + 1):
		k = k + i
	print((n % 10 - 1) * 10 + k)


import sys
t = int(sys.stdin.readline().strip())
for _ in range(t):
	respond = int(sys.stdin.readline().strip())
	digit = respond % 10
	out = 0
	for d in range(1, digit):
		out += 10
	if respond < 10:
		out += 1
	elif respond < 100:
		out += 3
	elif respond < 1000:
		out += 6
	elif respond < 10000:
		out += 10
	print(out)


t = int(input())
while t > 0:
	n = int(input())
	sum = 0
	k = str(n)
	v = int(k[0])
	sum = sum + 10 * (v - 1)
	for i in range(0, len(k) + 1):
		sum += i
	print(sum)
	t -= 1


a = int(input())
c = [0] * a
for i in range(a):
	b = input()
	c[i] = 10 * (int(b[0]) - 1) + sum(list(range(len(b) + 1)))
for i in range(a):
	print(c[i])


for t in range(int(input())):
	N = input()
	d = {1: 1, 2: 3, 3: 6, 4: 10}
	print((int(N[0]) - 1) * 10 + d[len(N)])


li = []
for i in range(1, 10):
	for j in range(1, 5):
		li.append(str(i) * j)
k = int(input())
for rep in range(k):
	inp = input()
	sum = 0
	for o in li:
		sum += len(o)
		if inp == o:
			break
	print(sum)


from sys import stdin, stdout
for _ in range(int(input())):
	s1 = input()
	a = int(s1[0])
	l = len(s1)
	print(10 * (a - 1) + l * (l + 1) // 2)


def add():
	global count
	for i in range(1, 10):
		for j in range(1, 5):
			num = str(i) * j
			count += len(num)
			if num == room:
				return count
for r in range(int(input())):
	room = input()
	count = 0
	print(add())


def calls(answered: int) -> int:
	number = answered % 10
	return 10 * (number - 1) + sum([i for i in range(1, len(str(answered)) + 1)])

def main():
	results = []
	for _ in range(int(input())):
		answered = int(input())
		results.append(calls(answered))
	for r in results:
		print(r)
main()


def suum(n):
	x = str(n)
	return len(x)
for _ in range(int(input())):
	l = []
	for i in range(1, 10):
		x = str(i)
		p = x
		for j in range(4):
			y = int(x)
			l.append(y)
			x += p
	n = int(input())
	ind = l.index(n)
	p = l[:ind + 1]
	ans = 0
	for i in range(len(p)):
		ans += suum(l[i])
	print(ans)


for i in range(int(input())):
	x = input()
	c = int(x[0])
	k = int(len(x))
	print((c - 1) * 10 + k * (k + 1) // 2)


t = int(input())
for i in range(t):
	n = int(input())
	s = str(n)
	x = s[0]
	x = int(x)
	sum = 0
	for i in range(1, x):
		sum = sum + 10
	a = len(s)
	if a == 1:
		sum += 1
	elif a == 2:
		sum += 3
	elif a == 3:
		sum += 6
	else:
		sum += 10
	print(sum)


from sys import stdin, stdout
import math
from collections import deque

def solve():
	n = str(input())
	dig = int(n[0])
	l = len(n)
	ans = 0
	if dig > 1:
		ans += 10 * (dig - 1)
	ans += l * (l + 1) // 2
	print(ans)
tt = 1
tt = int(input())
for __ in range(tt):
	solve()


import sys
import math
import itertools

def get_line():
	return list(map(int, sys.stdin.readline().strip().split()))

def in1():
	return int(input())
for _ in range(in1()):
	n = in1()
	n1 = list(str(n))
	t1 = int(n1[0])
	c = (t1 - 1) * 10
	if len(n1) == 1:
		c += 1
	elif len(n1) == 2:
		c += 3
	elif len(n1) == 3:
		c += 6
	else:
		c += 10
	print(c)


def answer():
	k = str(input())
	x = int(k[0])
	y = len([i for i in k])
	print(int((x - 1) * 10 + y * (y + 1) / 2))
test = int(input())
while test:
	answer()
	test -= 1


t = int(input())
for _ in range(t):
	n = input()
	r = int(n) % 10
	ans = (r - 1) * 10
	print(ans + len(n) * (len(n) + 1) // 2)


for _ in range(int(input())):
	ss = input()
	print(len(ss) * (len(ss) + 1) // 2 + 10 * (int(ss[0]) - 1))


def main():
	t = int(input())
	for test in range(t):
		n = input()
		ans = 0
		ans += 10 * (int(n[0]) - 1)
		ans += len(n) * (len(n) + 1) / 2
		print(int(ans))
main()


t = int(input())
k = 0
while t != 0:
	a = input()
	l = len(a)
	m = 0
	for i in range(l + 1):
		m += i
	print((int(a[0]) - 1) * 10 + m)
	t = t - 1


list = []
t = int(input())
for i in range(t):
	list.append(int(input()))

def sum(x):
	m = 0
	a = x % 11
	b = x % 111
	c = x % 1111
	if c == 0:
		c1 = x // 1111
		m = c1 * 10
	elif b == 0:
		b1 = x // 111
		m = b1 * 10
		m = m - 4
	elif a == 0:
		a1 = x // 11
		m = a1 * 10
		m = m - 7
	else:
		m = (x - 1) * 10 + 1
	return m
for i in range(t):
	print(sum(list[i]))


import sys
import math
from os import path
if path.exists('input.txt'):
	sys.stdin = open('input.txt', 'r')
	sys.stdout = open('output.txt', 'w')
l = [1, 11, 111, 1111, 2, 22, 222, 2222, 3, 33, 333, 3333, 4, 44, 444, 4444, 5, 55, 555, 5555, 6, 66, 666, 6666, 7, 77, 777, 7777, 8, 88, 888, 8888, 9, 99, 999, 9999]
for _ in range(int(input())):
	x = int(input())
	dig = 0
	ind = l.index(x)
	i = 0
	while i <= ind:
		dig += len(str(l[i]))
		i += 1
	print(dig)


def test():
	n = int(input())
	s = 0
	for i in range(1, 10):
		for j in range(1, 5):
			s += j
			if str(n) == ''.join([str(i)] * j):
				return s
for t in range(int(input())):
	print(test())


for _ in range(int(input())):
	x = input()
	br = False
	ans = 0
	for digit in '123456789':
		for num_digits in range(1, 5):
			ans += num_digits
			if digit * num_digits == x:
				br = True
				break
		if br:
			break
	print(ans)


l = []
for d in range(1, 10):
	for i in range(1, 5):
		l += [str(d) * i]
t = int(input())
for _ in range(t):
	x = input()
	print(sum(map(len, l[:l.index(x) + 1])))


t = int(input())
for i in range(t):
	x = int(input())
	a = 0
	while x > 0:
		a += 1
		y = x
		x = x // 10
	n = (y - 1) * 4 + a
	p = n // 4
	q = n % 4
	ans = p * 10 + q * (q + 1) // 2
	print(ans)


for __ in range(int(input())):
	x = input()
	a = int(x[0])
	l = len(x)
	sum = (a - 1) * 10
	if l == 1:
		sum += 1
	elif l == 2:
		sum += 3
	elif l == 3:
		sum += 6
	else:
		sum += 10
	print(sum)


t = int(input())
for i in range(t):
	n = int(input())
	x = list(str(n))
	f = int(x[0])
	val = 0
	if len(x) == 1:
		val = 1
	if len(x) == 2:
		val = 3
	if len(x) == 3:
		val = 6
	if len(x) == 4:
		val = 10
	print((f - 1) * 10 + val)


import string
nums = string.digits

def solve(num):
	size = 0
	for i in range(1, 10, 1):
		c = nums[i]
		for j in range(1, 5, 1):
			size += len(c * j)
			if num == int(c * j):
				print(size)
				return
n = int(input())
for i in range(n):
	solve(int(input()))


for tt in range(int(input())):
	n = input()
	ans = (int(n[0]) - 1) * 10 + 1 + len(n) * (1 + len(n)) // 2 - 1
	print(ans)


import sys
read = sys.stdin.readline
flush = sys.stdout.flush

def solution():
	ans = 0
	x = input()
	pre = int(x[0]) - 1
	ans += pre * 10
	for i in range(1, len(x) + 1):
		ans += i
	return ans

def main():
	T = int(read())
	for t in range(1, T + 1):
		print(solution())
main()


x = int(input())
for i in range(x):
	ch = input()
	h = set(ch)
	if len(ch) == 1:
		print(1 + (int(list(h)[0]) - 1) * 10)
	if len(ch) == 2:
		print(3 + (int(list(h)[0]) - 1) * 10)
	if len(ch) == 3:
		print(6 + (int(list(h)[0]) - 1) * 10)
	if len(ch) == 4:
		print(10 + (int(list(h)[0]) - 1) * 10)


for test in range(int(input())):
	n = input()
	seen = int(n[0]) - 1
	ct = seen * 10
	if len(n) == 1:
		ct += 1
	if len(n) == 2:
		ct += 3
	if len(n) == 3:
		ct += 6
	if len(n) == 4:
		ct += 10
	print(ct)


def solve(x):
	if x < 10:
		return (x - 1) * 10 + 1
	if x < 100:
		x //= 11
		return (x - 1) * 10 + 3
	if x < 1000:
		x //= 111
		return (x - 1) * 10 + 6
	if x < 10000:
		x //= 1111
		return x * 10
t = int(input())
for _ in range(t):
	x = int(input())
	print(solve(x))


import math
t = int(input())
for w in range(t):
	x = int(input())
	n = len(str(x))
	l = [1, 2, 3, 4, 5, 6, 7, 8, 9]
	print(l.index(int(str(x)[0])) * 10 + n * (n + 1) // 2)


t = int(input())
for _ in range(t):
	a = input()
	k = len(a)
	dig = int(a[0])
	print((dig - 1) * 10 + k * (k + 1) // 2)


t = int(input())
for i in range(0, t):
	x = int(input())
	s = str(x)
	f = s[0]
	count = 0
	z = 0
	y = 0
	for j in range(1, int(f) + 1):
		k = str(j)
		v = k
		if k != f:
			while int(k) < 10000:
				z += 1
				k += v
		else:
			y = len(str(x))
		while z > 0:
			count += z
			z -= 1
	while y > 0:
		count += y
		y -= 1
	print(count)


a = [1, 11, 111, 1111, 2, 22, 222, 2222, 3, 33, 333, 3333, 4, 44, 444, 4444, 5, 55, 555, 5555, 6, 66, 666, 6666, 7, 77, 777, 7777, 8, 88, 888, 8888, 9, 99, 999, 9999]
t = int(input())

def bor(n):
	s = a.index(n) + 1
	if s % 4 == 1:
		b = s // 4 * 10 + 1
	elif s % 4 == 2:
		b = s // 4 * 10 + 3
	elif s % 4 == 3:
		b = s // 4 * 10 + 6
	elif s % 4 == 0:
		b = s // 4 * 10
	return b
for xx in range(t):
	n = int(input())
	print(bor(n))


t = int(input())
for k in range(t):
	n = int(input())
	p = str(n)
	tot1 = (int(p[0]) - 1) * 10
	tot2 = 0
	for i in range(1, len(p) + 1):
		tot2 += i
	print(tot1 + tot2)


t = int(input())
resp = [0] * t
for i in range(0, t):
	n = int(input())
	aux = 1
	cont = 0
	string = list()
	string.append('1')
	aux2 = str('0')
	if n == 1:
		resp[i] = 1
	else:
		while aux2 != str(n):
			tam = len(string)
			cont += tam
			if tam == 4:
				aux += 1
				del string
				string = list()
				string.append(str(aux))
			else:
				string.append(str(string[0]))
			aux2 = ''.join(string)
		resp[i] = cont + len(str(n))
for i in range(0, t):
	print(resp[i])


def cmp(key):
	return key[0]
from math import floor, ceil
t = int(input())
answer = 0
a = [1, 11, 111, 1111]
for i in range(2, 10):
	a.append(a[0] * i)
	a.append(a[1] * i)
	a.append(a[2] * i)
	a.append(a[3] * i)
b = [1, 2, 3, 4]
b = b * 9
for i in range(t):
	x = int(input())
	for k in range(len(a)):
		answer = answer + b[k]
		if x == a[k]:
			break
	print(answer)
	answer = 0


t = int(input())
for tt in range(t):
	n = int(input())
	s = len(str(n))
	a = n % 10
	b = (a - 1) * 10 + s * (s + 1) // 2
	print(b)


import sys
from math import gcd, sqrt, ceil, log2
from collections import defaultdict, Counter, deque
from bisect import bisect_left, bisect_right
import math
import heapq
from itertools import permutations
import os
import sys
from io import BytesIO, IOBase
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
input = lambda : sys.stdin.readline().rstrip('\r\n')

def get_sum(bit, i):
	s = 0
	i += 1
	while i > 0:
		s += bit[i]
		i -= i & -i
	return s

def update(bit, n, i, v):
	i += 1
	while i <= n:
		bit[i] += v
		i += i & -i

def modInverse(b, m):
	g = math.gcd(b, m)
	if g != 1:
		return -1
	else:
		return pow(b, m - 2, m)

def primeFactors(n):
	sa = set()
	sa.add(n)
	while n % 2 == 0:
		sa.add(2)
		n = n // 2
	for i in range(3, int(math.sqrt(n)) + 1, 2):
		while n % i == 0:
			sa.add(i)
			n = n // i
	return sa

def seive(n):
	pri = [True] * (n + 1)
	p = 2
	while p * p <= n:
		if pri[p] == True:
			for i in range(p * p, n + 1, p):
				pri[i] = False
		p += 1
	return pri

def check_prim(n):
	if n < 0:
		return False
	for i in range(2, int(sqrt(n)) + 1):
		if n % i == 0:
			return False
	return True

def getZarr(string, z):
	n = len(string)
	(l, r, k) = (0, 0, 0)
	for i in range(1, n):
		if i > r:
			(l, r) = (i, i)
			while r < n and string[r - l] == string[r]:
				r += 1
			z[i] = r - l
			r -= 1
		else:
			k = i - l
			if z[k] < r - i + 1:
				z[i] = z[k]
			else:
				l = i
				while r < n and string[r - l] == string[r]:
					r += 1
				z[i] = r - l
				r -= 1

def search(text, pattern):
	concat = pattern + '$' + text
	l = len(concat)
	z = [0] * l
	getZarr(concat, z)
	ha = []
	for i in range(l):
		if z[i] == len(pattern):
			ha.append(i - len(pattern) - 1)
	return ha

def mergeIntervals(arr):
	arr.sort(key=lambda x: x[0])
	m = []
	s = -10000
	max = -100000
	for i in range(len(arr)):
		a = arr[i]
		if a[0] > max:
			if i != 0:
				m.append([s, max])
			max = a[1]
			s = a[0]
		elif a[1] >= max:
			max = a[1]
	if max != -100000 and [s, max] not in m:
		m.append([s, max])
	return m
t = int(input())
for _ in range(t):
	x = str(input())
	ans = 0
	i = '1'
	while i != x:
		ans += len(str(i))
		i += i[0]
		if len(i) == 5:
			i = str(int(i[0]) + 1)
	ans += len(str(i))
	print(ans)


borings = list()
for num in '123456789':
	for x in range(1, 5):
		borings.append(num * x)
for x in range(int(input())):
	answer = input()
	presses = 0
	for boring_apt in borings:
		presses += len(boring_apt)
		if boring_apt == answer:
			print(presses)


for t in range(int(input())):
	n = int(input())
	l = len(str(n))
	x = str(n)[0]
	s = 10 * (int(x) - 1)
	for i in range(1, l + 1):
		s = s + i
	print(s)


t = int(input())
i = 0
while t > i:
	i = i + 1
	x = int(input())
	lng = len(str(x))
	y = lng
	x_str = str(x)
	num = 1
	num = (int(x_str[0]) - 1) * 10
	num = num + y * (y + 1) / 2
	print(int(num))


t = input()
while int(t) > 0:
	x = input()
	digit = int(x) % 10
	key = 10 * (digit - 1)
	if len(x) == 1:
		print(key + 1)
	if len(x) == 2:
		print(key + 3)
	if len(x) == 3:
		print(key + 6)
	if len(x) == 4:
		print(key + 10)
	t = int(t) - 1


def plus(x):
	sum = 0
	for i in range(x, 0, -1):
		sum += i
	return sum
for i in range(int(input())):
	x = int(input())
	l = len(str(x))
	print(x % 10 * 10 - (10 - plus(l)))


def p(n):
	sum_ = 0
	for x in range(1, n + 1):
		sum_ += x
	return sum_

def solve(s):
	n = int(s)
	f = int(s[0])
	return p(4) * (f - 1) + p(len(s))

def main(input_path=0):
	with open(input_path) as f:
		t = int(f.readline())
		for _ in range(t):
			n = f.readline().strip()
			print(solve(n))
main()


t = int(input())
while t > 0:
	t -= 1
	n = input()
	max1 = 10
	l = [1, 2, 3, 4]
	last = int(n[-1]) % 10
	ans = 0
	for i in range(1, last):
		ans += max1
	for i in range(len(n)):
		ans += l[i]
	print(ans)


import math

def boring_apartments(x):
	count = 0
	for i in range(1, 10):
		current = 0
		for j in range(4):
			current += int(math.pow(10, j)) * i
			count += j + 1
			if current == x:
				return count
	return count

def main():
	t = int(input())
	while t > 0:
		x = int(input())
		ans = boring_apartments(x)
		print(ans)
		t -= 1
main()


from functools import reduce
import collections
import math
import sys

class Read:

	@staticmethod
	def string():
		return input()

	@staticmethod
	def int():
		return int(input())

	@staticmethod
	def list(delimiter=' '):
		return input().split(delimiter)

	@staticmethod
	def list_int(delimiter=' '):
		return list(map(int, input().split(delimiter)))

def main():
	t = Read.int()
	for _ in range(t):
		a = Read.string()
		res = (int(a[0]) - 1) * 10
		if len(a) == 1:
			res += 1
		elif len(a) == 2:
			res += 3
		elif len(a) == 3:
			res += 6
		elif len(a) == 4:
			res += 10
		print(res)
main()


T = int(input())
for _ in range(T):
	n = int(input())
	ans = (n % 10 - 1) * 10
	if n > 1000:
		ans += 10
	elif n > 100:
		ans += 6
	elif n > 10:
		ans += 3
	else:
		ans += 1
	print(ans)


for _ in range(int(input())):
	s = str(input())
	n = len(s)
	a = int(s[0])
	if s[0] != '1':
		print(int(10 * (a - 1) + (1 + n) * n * 0.5))
	else:
		print(int((1 + n) * n * 0.5))


T = int(input())
for t in range(T):
	x = input()
	num = int(x[0])
	total = (num - 1) * 10
	count = 1
	for i in range(len(x)):
		total += count
		count += 1
	print(total)


import math

def countDigit(n):
	return math.floor(math.log(n, 10) + 1)
t = int(input())
for T in range(t):
	n = int(input())
	x = countDigit(n)
	m = str(n)
	res = list(map(int, str(n)))
	y = res[0]
	ans = 10 * (y - 1)
	if len(m) == 1:
		ans += 1
	if len(m) == 2:
		ans += 3
	if len(m) == 3:
		ans += 6
	if len(m) == 4:
		ans += 10
	print(ans)


t = int(input())
for tc in range(t):
	n = input()
	ans = (int(n[0]) - 1) * 10 + len(n) * (len(n) + 1) // 2
	print(ans)


t = int(input())
a = [1, 3, 6, 10]
while t > 0:
	x = input()
	print((int(x[0]) - 1) * 10 + a[len(x) - 1])
	t -= 1


for _ in range(int(input())):
	x = int(input())
	ans = 0
	temp = str(x)
	temp = temp[0]
	ans = int(temp) - 1
	ans = ans * 10
	no = str(x)
	l = len(no)
	if l == 1:
		ans += 1
	elif l == 2:
		ans += 3
	elif l == 3:
		ans += 6
	else:
		ans += 10
	print(ans)


inp = lambda : int(input())
strl = lambda : list(input().strip())
seq = lambda : list(map(int, input().strip().split()))

def f(x):
	xx = len(str(x))
	cnt = 0
	xy = int(str(x)[0]) - 1
	cnt += 10 * xy
	while xx > 0:
		cnt += xx
		xx -= 1
	return cnt

def main():
	t = inp()
	for _ in range(t):
		n = inp()
		result = f(n)
		print(result)
main()


t = int(input())
for i in range(t):
	n = input()
	a = n[0]
	res = (int(a) - 1) * 10
	for i in range(len(n)):
		res += i + 1
	print(res)


def solve(a):
	first = 10 * (int(str(a)[0]) - 1)
	second = 0
	if len(str(a)) == 1:
		second = 1
	if len(str(a)) == 2:
		second = 3
	if len(str(a)) == 3:
		second = 6
	if len(str(a)) == 4:
		second = 10
	return first + second
t = int(input())
out = []
for i in range(t):
	a = input()
	out.append(solve(a))
for x in out:
	print(x)


from sys import stdin, stdout
n = int(stdin.readline())
for i in range(n):
	k = int(stdin.readline())
	cyc = k % 10
	ans = 0
	ans += cyc * 10
	ans -= 10
	k = str(k)
	a = len(k)
	ans += a * (a + 1) // 2
	stdout.write(str(ans) + '\n')


t = int(input())
for i in range(t):
	n = int(input())
	flag = False
	ans = 0
	for i in range(1, 10):
		s = 0
		for j in range(0, 4):
			s += 10 ** j * i
			ans += j + 1
			if n == s:
				print(ans)
				flag = True
				break
		if flag:
			break


for _ in range(int(input())):
	s = input()
	k = int(s[0])
	k1 = len(s)
	sm = 0
	for i in range(1, k1 + 1):
		sm += i
	print((k - 1) * 10 + sm)


import os
import sys
from io import BytesIO, IOBase
import heapq as h
from bisect import bisect_left, bisect_right
from types import GeneratorType
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		import os
		self.os = os
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = self.os.read(self._fd, max(self.os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = self.os.read(self._fd, max(self.os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			self.os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
input = lambda : sys.stdin.readline().rstrip('\r\n')
import collections as col

def getInts():
	return [int(s) for s in input().split()]

def getInt():
	return int(input())

def getStrs():
	return [s for s in input().split()]

def getStr():
	return input()

def listStr():
	return list(input())
MOD = 10 ** 9 + 7

def solve():
	N = getInt()
	x = int(str(N)[0])
	L = len(str(N))
	return (x - 1) * 10 + L * (L + 1) // 2
for _ in range(getInt()):
	print(solve())


a = [[int(str(i) * j) for j in range(1, 5)] for i in range(1, 10)]
b = []

def solve():
	n = int(input())
	for i in range(9):
		for j in range(4):
			if a[i][j] == n:
				nm = 0
				mn = 1
				for k in range(j + 1):
					nm += mn
					mn += 1
				b.append(i * 10 + nm)
t = int(input())
for i in range(t):
	solve()
for i in range(t):
	print(b[i])


from collections import defaultdict
for _ in range(int(input())):
	n = int(input())
	d = defaultdict(int)
	sm = 0
	for i in range(1, 10):
		for j in range(1, 5):
			sm += j
			res = int(str(i) * j)
			d[res] = sm
	if n == 12:
		print(12)
		continue
	print(d[n])


cases = int(input())
for case in range(cases):
	x = input()
	initialVal = (int(x[0]) - 1) * 10
	for i in range(1, len(x) + 1):
		initialVal += i
	print(initialVal)


t = int(input())
for i in range(t):
	n = input()
	q = int(n[0])
	w = len(n)
	print(10 * (q - 1) + w * (w + 1) // 2)


t = int(input())
mas = []
cst = []
for _ in range(1, 10):
	for __ in range(1, 5):
		mas.append(int(str(_) * __))
		cst.append(__)
for _ in range(t):
	a = int(input())
	ans = 0
	for i in range(len(mas)):
		if mas[i] == a:
			ans += sum(cst[:i + 1])
	print(ans)


t = int(input())
for i in range(t):
	x = int(input())
	start = 1
	al = 0
	while x % 10 != start % 10:
		al += 10
		start += 1
	al += (len(str(x)) + 1) * len(str(x)) // 2
	print(al)


n = int(input())
a = []
digits = 0
value = []
for i in range(n):
	n1 = int(input())
	a.append(n1)
for i in range(n):
	n2 = a[i] % 10
	digits = 10 * (n2 - 1)
	count = 0
	while a[i] > 0:
		count = count + 1
		a[i] = a[i] // 10
		add = 0
	for i in range(count + 1):
		add = add + i
	digits = digits + add
	value.append(digits)
for i in range(n):
	print(value[i])


t = int(input())
for i in range(t):
	x = str(input())
	print(sum(((1, 2, 3, 4) * int(x[0]))[:4 * (int(x[0]) - 1) + len(x)]))


n = int(input())
for i in range(n):
	x = int(input())
	otv = (x % 10 - 1) * 10
	if len(str(x)) == 1:
		otv += 1
	elif len(str(x)) == 2:
		otv += 3
	elif len(str(x)) == 3:
		otv += 6
	elif len(str(x)) == 4:
		otv += 10
	print(otv)


l = [1, 11, 111, 1111]
l3 = [1, 3, 6, 10]
l2 = []
v = []
for i in range(2, 10):
	result = list(map(lambda x: x * i, l))
	l2 = l2 + result
l = l + l2
n = int(input())
for i in range(n):
	k = int(input())
	index = l.index(k) + 1
	a = index // 4 * 10
	c = index % 4 - 1
	if c >= 0:
		b = l3[c]
	else:
		b = 0
	m = a + b
	v.append(m)
print(*v, sep='\n')


t = int(input())
l = []
for i in range(1, 10):
	s = ''
	for j in range(4):
		s += str(i)
		l.append(s)
for i in range(t):
	count = 0
	x = str(input())
	for item in l:
		if x == item:
			count += len(item)
			break
		else:
			count += len(item)
	print(count)


for _ in range(int(input())):
	N = input()
	A = len(N)
	B = int(N[0]) - 1
	ans = B * 10 + A * (A + 1) // 2
	print(ans)


t = int(input())
N = []

def count1(n):
	c = 0
	while n > 0:
		n = int(n / 10)
		c += 1
	return c
for i in range(t):
	n = int(input())
	N.append(n)
for i in range(t):
	x = N[i] % 10
	y = count1(N[i])
	count = 0
	for j in range(x - 1):
		count += 10
	for j in range(1, y + 1):
		count += j
	print(count)


t = input('')
t = int(t)
for i in range(0, t):
	x = input('')
	n = len(x)
	x = int(x)
	m = x % 10
	count = 0
	for j in range(1, m):
		count = count + 10
	for c in range(1, n + 1):
		count = count + c
	print(count)


t = int(input())
i = 0
dic = {1: 1, 2: 3, 3: 6, 4: 10}
while i < t:
	n = int(input())
	a = int(str(n)[0]) - 1
	b = dic[len(str(n))]
	a = a * 10
	print(a + b)
	i += 1


t = int(input())
for _ in range(t):
	s = input()
	ans = 0
	ans += (int(s[-1]) - 1) * 10
	for i in range(len(s)):
		ans += i + 1
	print(ans)


t = int(input())
while t:
	t = t - 1
	n = int(input())
	s = str(n)
	if len(s) >= 2:
		if s[1] == '0':
			d = len(s)
			if d == 2:
				print(92)
			elif d == 3:
				print(95)
			elif d == 4:
				print(99)
			else:
				print(104)
		else:
			c = (int(s[0]) - 1) * 10
			for i in range(1, len(s) + 1):
				c = c + i
			print(c)
	else:
		c = (int(s[0]) - 1) * 10
		print(c + 1)


t = int(input())
for i in range(t):
	x = input()
	res = 0
	flag = 0
	for i in range(1, 10):
		for j in range(1, 5):
			res += j
			if str(i) * j == x:
				print(res)
				flag = 1
				break
		if flag == 1:
			break


def apps(x):
	ret = []
	y = x
	for _ in range(4):
		ret.append(y)
		y = y * 10
		y = y + x
	return ret

def boring(x):
	k = str(x)
	z = 1
	count = 0
	for _ in range(int(k[0]) + 1):
		if _ != 0:
			lst = apps(_)
			for __ in lst:
				count = count + len(str(__))
				if x == int(__):
					return count
inp = []
t = int(input())
w = 0
if t >= 1 and t <= 36:
	for _ in range(t):
		x = int(input())
		inp.append(x)
		w = w + 1
else:
	print('invalid input')
if w == t:
	for ___ in inp:
		print(boring(int(___)))
else:
	print('invalid input')


n = int(input())
for i in range(1, n + 1):
	count = 0
	a = int(input())
	for j in range(1, 10):
		b = [1, 11, 111, 1111]
		c = [k * j for k in b]
		for k in range(4):
			count += k + 1
			if a == c[k]:
				print(count)
				break


l = []
for k in range(1, 10):
	for j in range(1, 5):
		l.append(int(str(k) * j))
n = int(input())
for i in range(n):
	k = 0
	ans = 0
	num = int(input())
	while l[k] != num:
		ans += len(str(l[k]))
		k += 1
	print(ans + len(str(num)))


t = int(input())
for _ in range(t):
	x = input()
	c = x.count(x[0])
	total = (int(x[0]) - 1) * 10
	total += c * (c + 1) // 2
	print(total)


def digits(x):
	result = (x % 10 - 1) * 10
	for i in range(len(str(x))):
		result = result + i + 1
	return result
t = int(input())
for _ in range(t):
	x = int(input())
	print(digits(x))


import re

def readGenerator():
	while True:
		tokens = input().split(' ')
		for t in tokens:
			yield t
reader = readGenerator()

def readWord():
	return next(reader)

def readInt():
	return int(next(reader))

def readFloat():
	return float(next(reader))

def readLine():
	return input()

def solve(n):
	f = n[0]
	l = [1, 2, 3, 4]
	res = 10 * (int(f) - 1) + sum(l[0:len(n)])
	return res
t = readInt()
for _ in range(t):
	n = readLine()
	print(solve(n))


import math
for _ in range(int(input())):
	n = int(input())
	lst = [1, 11, 111, 1111, 2, 22, 222, 2222, 3, 33, 333, 3333, 4, 44, 444, 4444, 5, 55, 555, 5555, 6, 66, 666, 6666, 7, 77, 777, 7777, 8, 88, 888, 8888, 9, 99, 999, 9999]
	pos = lst.index(n)
	digits = 0
	for i in range(pos + 1):
		digits += int(math.floor(math.log(lst[i], 10)) + 1)
	print(digits)


g = []
for number in range(1, 10):
	for k in range(1, 5):
		g.append(k * str(number))
q = int(input())
for i in range(q):
	a = input()
	ans = 0
	for i in g:
		if i != a:
			ans += len(i)
		else:
			print(ans + len(a))
			break


for testcase in range(int(input())):
	x = int(input())
	a = x
	digit = x % 10
	c = len(str(a))
	if c == 1:
		print(digit * 10 - 10 + 1)
	elif c == 2:
		print(digit * 10 - 10 + 3)
	elif c == 3:
		print(digit * 10 - 10 + 6)
	elif c == 4:
		print(digit * 10)


def boring(num):
	numstr = str(num)
	length = len(numstr)
	first = int(numstr[0])
	appartment = 10 * (first - 1)
	if length == 1:
		appartment += 1
	elif length == 2:
		appartment += 3
	elif length == 3:
		appartment += 6
	elif length == 4:
		appartment += 10
	return appartment
n = int(input())
for i in range(n):
	num = int(input())
	print(boring(num))


t = int(input())
while t:
	n = int(input())
	no = n % 10
	length = 0
	while n != 0:
		length += 1
		n = n // 10
	ans = 10 * (no - 1)
	ans += length * (length + 1) // 2
	print(ans)
	t -= 1


import sys
import math
import bisect
from sys import stdin, stdout
from math import gcd, floor, sqrt, log2, ceil
from collections import defaultdict as dd
from bisect import bisect_left as bl, bisect_right as br
from bisect import insort
from collections import Counter
from collections import deque
from heapq import heappush, heappop, heapify
from itertools import permutations, combinations
mod = int(1000000000.0) + 7
ip = lambda : int(stdin.readline())
inp = lambda : map(int, stdin.readline().split())
ips = lambda : stdin.readline().rstrip()
out = lambda x: stdout.write(str(x) + '\n')
t = ip()
for _ in range(t):
	s = ips()
	n = int(s[0])
	ans = (n - 1) * 10
	ans += len(s) * (len(s) + 1) // 2
	out(ans)


aux = {}
valor = 0
for i in range(1, 10):
	aux[str(i) * 1] = valor + len(str(i) * 1)
	valor += len(str(i) * 1)
	aux[str(i) * 2] = valor + len(str(i) * 2)
	valor += len(str(i) * 2)
	aux[str(i) * 3] = valor + len(str(i) * 3)
	valor += len(str(i) * 3)
	aux[str(i) * 4] = valor + len(str(i) * 4)
	valor += len(str(i) * 4)
for _ in range(int(input())):
	print(aux[input()])


def lis():
	return [int(x) for x in input().split()]

def intt():
	return int(input())

def st():
	return str(input())
t = intt()
for i in range(t):
	x = intt()
	ans = 0
	tp = str(x)
	temp = int(tp[0])
	ans += 10 * (temp - 1)
	ans += len(tp) * (len(tp) + 1) // 2
	print(ans)


for _ in range(int(input())):
	k = 10
	ans = 0
	n = input()
	arr = [int(c) for c in n]
	m = arr[0]
	p = 0
	if len(arr) == 1:
		p = 1
	elif len(arr) == 2:
		p = 3
	elif len(arr) == 3:
		p = 6
	elif len(arr) == 4:
		p = 10
	ans = (m - 1) * k + p
	print(ans)


t = int(input())
for _ in range(t):
	x = int(input())
	d = 1
	ds = 1
	num = d
	count = 0
	while num != x:
		num = num * 10 + d
		if num > 10000:
			d += 1
			count += ds
			ds = 1
			num = d
		else:
			count += ds
			ds += 1
	print(count + ds)


t = int(input())
while t > 0:
	x = int(input())
	apartment = '1'
	digit = '1'
	lengther = 0
	while apartment != str(x):
		if int(apartment) < 10000:
			lengther += len(apartment)
			apartment += str(digit)
		else:
			digit = int(digit) + 1
			apartment = str(digit)
	print(lengther + len(apartment))
	t -= 1


t = int(input())
for z in range(t):
	x = int(input())
	temp = int(x)
	digCount = 0
	while temp != 0:
		temp = temp // 10
		digCount = digCount + 1
	digit = x % 10
	a = digCount * (digCount + 1) / 2
	b = (digit - 1) * 10
	print(int(a + b))


n = int(input())
z = [0, 1, 3, 6, 10]
for i in range(n):
	m = int(input())
	res = (m % 10 - 1) * 10
	res += z[len(str(m))]
	print(res)


t = int(input())
for i in range(t):
	apartment = int(input())
	apartment_string = str(apartment)
	answer = 0
	answer += (int(apartment_string[0]) - 1) * 10
	answer += int(len(apartment_string) * (len(apartment_string) + 1) * 0.5)
	print(answer)


numcases = int(input())
num = ''
size = 0
ans = 0
for i in range(numcases):
	lim = input()
	num = int(lim[0])
	size = len(lim)
	ans = (num - 1) * 10
	if len(lim) == 1:
		ans += 1
	elif len(lim) == 2:
		ans += 3
	elif len(lim) == 3:
		ans += 6
	elif len(lim) == 4:
		ans += 10
	print(ans)


t = int(input())
for _ in range(t):
	x = int(input())
	length = len(str(x))
	first_digit = x // 10 ** (length - 1)
	result = (first_digit - 1) * sum(range(1, 4 + 1)) + sum(range(1, length + 1))
	print(result)


import sys

def rs():
	return sys.stdin.readline().rstrip()

def ri():
	return int(sys.stdin.readline())

def ria():
	return list(map(int, sys.stdin.readline().split()))

def ws(s):
	sys.stdout.write(s + '\n')

def wi(n):
	sys.stdout.write(str(n) + '\n')

def wia(a):
	sys.stdout.write(' '.join([str(x) for x in a]) + '\n')
import math
from collections import defaultdict
for _ in range(ri()):
	n = rs()
	cnt = 10 * (int(n[0]) - 1)
	if len(n) == 1:
		cnt += 1
	elif len(n) == 2:
		cnt += 3
	elif len(n) == 3:
		cnt += 6
	elif len(n) == 4:
		cnt += 10
	wi(cnt)


a = int(input())
for i in range(a):
	b = int(input())
	b1 = int(str(b)[0])
	a1 = (b1 - 1) * 10
	if b < 10:
		a1 += 1
	elif b < 100:
		a1 += 3
	elif b < 1000:
		a1 += 6
	else:
		a1 += 10
	print(a1)


for q in range(int(input())):
	x = int(input())
	print((x - 1) % 10 * 10 + sum([i for i in range(1, len(str(x)) + 1)]))


for _ in range(int(input())):
	n = input()
	a = []
	for i in range(1, 10):
		a.append(str(i) * 1)
		a.append(str(i) * 2)
		a.append(str(i) * 3)
		a.append(str(i) * 4)
	x = a.index(n)
	a = a[:x + 1]
	y = ''.join(a)
	print(len(y))


n = int(input())
for i in range(n):
	x = int(input())
	a = len(str(x))
	f = int(str(x)[0:1])
	count = (f - 1) * 10
	while a > 0:
		count += a
		a -= 1
	print(count)


n = int(input())
a = []
for i in range(n):
	a.append(int(input()))
b = []
for i in a:
	c = (int(str(i)[0]) - 1) * 10
	c += (1 + len(str(i))) * len(str(i)) // 2
	b.append(c)
for i in b:
	print(i)


t = int(input())
for i in range(t):
	n = int(input())
	d = n % 10
	l = len(str(n))
	r = 10 * (d - 1) + l * (l + 1) // 2
	print(r)


def main(x):
	y = list(x)
	z = (int(y[0]) - 1) * 10
	index = len(y)
	d = 0
	while index > 0:
		d = d + index
		index = index - 1
	i = z + d
	return i
t = int(input())
for t_itr in range(t):
	x = input()
	res = main(x)
	print(res)


for _ in range(int(input())):
	n = int(input())
	ans = 0
	for i in range(1, 10):
		f = 0
		for j in range(1, 5):
			k = int(str(i) * j)
			ans += len(str(k))
			if k == n:
				f = 1
				break
		if f:
			break
	print(ans)


t = int(input())
for i in range(t):
	x = input()
	c = int(x[0]) - 1
	z = c * 10
	for j in range(1, len(x) + 1):
		z += j
	print(z)


def calculate(n):
	copy = n
	c = 0
	digit = copy % 10
	while copy > 0:
		c += 1
		copy = int(copy / 10)
	if c == 4:
		total = (digit - 1) * 10 + 10
	if c == 3:
		total = (digit - 1) * 10 + 6
	if c == 2:
		total = (digit - 1) * 10 + 3
	if c == 1:
		total = (digit - 1) * 10 + 1
	return total
n = int(input())
L = []
for i in range(n):
	L.append(calculate(int(input())))
for i in range(len(L)):
	print(L[i])


t = int(input())
for j in range(1, t + 1):
	S = 0
	x = input()
	for i in range(1, int(x[0])):
		S = S + 10
	for k in range(0, len(x) + 1):
		S = S + k
	print(S)


import os
import sys
from io import BytesIO, IOBase
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
input = lambda : sys.stdin.readline().rstrip('\r\n')
from math import gcd, ceil

def prod(a, mod=10 ** 9 + 7):
	ans = 1
	for each in a:
		ans = ans * each % mod
	return ans

def lcm(a, b):
	return a * b // gcd(a, b)

def binary(x, length=16):
	y = bin(x)[2:]
	return y if len(y) >= length else '0' * (length - len(y)) + y
s = []
if 1:
	for i in range(1, 10):
		x = i
		for j in range(4):
			s += [x]
			x *= 10
			x += i
for _ in range(int(input()) if True else 1):
	n = int(input())
	print(len(''.join((str(k) for k in s[:s.index(n) + 1]))))


dict = {1: 1, 2: 3, 3: 6, 4: 10}
n = int(input())
lst = []
for i in range(0, n):
	x = input()
	val = 10 * (int(str(x)[0]) - 1) + dict.get(len(str(x)))
	lst.append(val)
print('\n'.join(map(str, lst)))


t = int(input())
while t:
	a = input()
	b = int(a)
	c = b % 10
	k = len(a)
	print(int(k * (k + 1) / 2 + (c - 1) * 10))
	t = t - 1


t = int(input())
mp = {1: 1, 2: 3, 3: 6, 4: 10}
while t:
	t -= 1
	n = input()
	total = (int(n[0]) - 1) * 10
	total += mp[len(n)]
	print(total)


cases = int(input())
for tc in range(cases):
	num = input()
	a = int(num[0])
	cnt = (a - 1) * 10
	cnt += (len(num) + 1) * len(num) // 2
	print(cnt)


for _ in range(int(input())):
	n = int(input())
	s = str(n)
	s1 = s[0]
	sum = 0
	for i in range(1, len(s) + 1):
		sum = sum + i
	print(sum + (int(s1) - 1) * 10)


import math

def le(n):
	x = 0
	while n != 0:
		r = n % 10
		n // 10
		x = x + 1
	return x
for t in range(int(input())):
	l = int(input())
	x = math.floor(math.log(l, 10) + 1)
	y = l % 10
	s = 0
	z = 0
	if y == 1:
		for i in range(1, x + 1):
			s += i
		print(s)
	else:
		z = y - 1
		g = z * 10
		for i in range(1, x + 1):
			s += i
		print(s + g)


n = int(input())
for _ in range(0, n):
	x = input()
	l = len(x)
	if l == 4:
		press = 10 * int(x[0])
	else:
		press = 10 * (int(x[0]) - 1) + l * (l + 1) / 2
	print(int(press))


t = int(input())
for q in range(t):
	n = int(input())
	a = len(str(n))
	b1 = n % 10
	b = (b1 - 1) * 10
	c = a * (a + 1) // 2
	print(b + c)


tt = int(input())
for _ in range(tt):
	n = int(input())
	s = str(n)[0]
	k = 10
	new = int(s) * k - k
	for i in range(1, len(str(n)) + 1):
		new += i
	print(new)


import sys
li = [1, 2, 3, 4]
a = int(sys.stdin.readline().strip())
for _ in range(a):
	num = sys.stdin.readline().strip()
	row = int(num[0])
	col = len(num)
	ans = (row - 1) * 10 + sum(li[0:col])
	print(ans)


L = []
for i in range(1, 10):
	x = str(i)
	L.append(x)
	L.append(x * 2)
	L.append(x * 3)
	L.append(x * 4)
t = int(input())
for i in range(0, t):
	s = str(input())
	count = 0
	i = 0
	while L[i] != s:
		count += len(L[i])
		i += 1
	count += len(L[i])
	print(count)


t = int(input())
list = []
for i in range(t):
	x = int(input())
	s = str(x)
	m = len(s)
	if m != 1:
		x0 = x % 10 * 10
		if m == 3:
			x0 -= 4
		if m == 2:
			x0 -= 7
	else:
		x0 = x * 10 - 9
	list.append(x0)
for j in range(t):
	print(list[j])


for _ in range(int(input())):
	n = input()
	x = int(n[0])
	l = [1, 2, 3, 4]
	ans = 10 * (x - 1) + sum(l[:len(n)])
	print(ans)


data = []
for i in range(1, 10):
	temp = [str(i) * j for j in range(1, 5)]
	data += temp
	temp = []
for _ in range(int(input())):
	n = input()
	s = 0
	for i in data:
		if i == n:
			s += len(i)
			print(s)
			break
		s += len(i)


import math as mt
import bisect
import sys
input = sys.stdin.readline
t = int(input())
import collections
import heapq
p = 10 ** 9 + 7

def ncr_util():
	inv[0] = inv[1] = 1
	fact[0] = fact[1] = 1
	for i in range(2, 300001):
		inv[i] = inv[i % p] * (p - p // i) % p
	for i in range(1, 300001):
		inv[i] = inv[i - 1] * inv[i] % p
		fact[i] = fact[i - 1] * i % p

def solve():
	l = []
	x1 = x % 10
	suma = 0
	mul = 1
	for i in range(4):
		suma = suma * 10 + x1
		if suma <= x:
			l.append(suma)
		mul *= 10
	ans = 0
	for i in range(1, x1):
		ans += 4
	return (x1 - 1) * 10 + len(l) * (len(l) + 1) // 2
for _ in range(t):
	x = int(input())
	print(solve())


t = int(input())
while t != 0:
	s = input()
	p = len(s)
	n = int(s[0]) - 1
	print(n * 10 + p * (p + 1) // 2)
	t = t - 1


a = []
v = []
for i in range(1, 10):
	x = 0
	for j in range(4):
		x = x * 10 + i
		a.append(x)
		v.append(j + 1)
T = int(input())
for i in range(T):
	x = int(input())
	ans = 0
	for j in range(len(a)):
		ans = ans + v[j]
		if a[j] == x:
			print(ans)


t = int(input())
for _ in range(t):
	n = int(input())
	tes = n % 10
	count = 0
	length = len(str(n))
	for i in range(1, 10):
		if i == tes:
			count += length * (1 + length) // 2
			print(count)
			break
		else:
			count += 10


sol = []
for t in range(int(input())):
	n = input()
	x = int(n) % 10
	y = len(n)
	rpta = (x - 1) * 10 + y * (y + 1) / 2
	sol.append(int(rpta))
for j in sol:
	print(j)


t = int(input())
for _ in range(t):
	x = int(input())
	k = len(str(x))
	if x % 10 == 1:
		print(k * (k + 1) // 2)
	else:
		a = k * (k + 1) // 2
		print((x % 10 - 1) * 10 + a)


for _ in range(int(input())):
	x = int(input())
	arr = []
	temp = '1'
	s = ''
	while True:
		s += temp[0]
		if int(s) > 10000:
			temp = str(int(temp) + 1)
			s = ''
		else:
			arr.append(s)
		if x == int(arr[-1]):
			break
		if int(temp) > 9:
			break
	res = 0
	for i in range(len(arr)):
		for j in range(len(arr[i])):
			res += 1
	print(res)


for x in range(int(input())):
	num = input()
	count = [1, 3, 6, 10]
	i = int(num[0]) - 1
	j = len(num) - 1
	res = 10 * i + count[j]
	print(res)


for T in range(int(input())):
	n = int(input())
	res = 0
	flag = False
	for i in range(1, 10):
		stack = [str(i)]
		while stack:
			q = stack.pop(0)
			if int(q) == n:
				res += len(q)
				flag = True
				break
			elif int(q) <= 9999:
				res += len(q)
				stack.append(q + q[-1])
		if flag:
			break
	print(res)


for _ in range(int(input())):
	x = int(input())
	st_x = str(x)
	value = int(st_x[0])
	ans = 10 * (value - 1)
	str_len = len(st_x)
	for i in range(1, str_len + 1):
		ans += i
	print(ans)


t = int(input())
for _ in range(t):
	n = int(input())
	s = 0
	for i in range(1, 10):
		j = i
		r = 0
		while j <= 10000:
			s = s + len(str(j))
			if j == n:
				r = 1
				break
			j = j * 10 + i
		if r == 1:
			break
	print(s)


count_match = {1: 1, 2: 3, 3: 6, 4: 10}
for _ in range(int(input())):
	number = input()
	pressedNumber = (int(number[0]) - 1) * 10 + count_match[len(number)]
	print(pressedNumber)


from math import *
t = int(input())
for i in range(t):
	n = int(input())
	ans = 10 * (n % 10 - 1)
	while n:
		k = n
		while k:
			k //= 10
			ans += 1
		n //= 10
	print(ans)


for i in range(int(input())):
	s = input()
	if len(s) == 1:
		a = int(s[0])
		print((a - 1) * 10 + 1)
	elif len(s) == 2:
		a = int(s[0])
		print((a - 1) * 10 + 3)
	elif len(s) == 3:
		a = int(s[0])
		print((a - 1) * 10 + 6)
	elif len(s) == 4:
		print(int(s[0]) * 10)


n = int(input())
anw = []
for _ in range(n):
	room = input()
	anw.append((int(room[0]) - 1) * 10 + (len(room) + 1) * len(room) / 2)
for i in range(len(anw)):
	print(int(anw[i]))


t = int(input())
for i in range(t):
	x = int(input())
	if x == 1:
		print(1)
	if 2 <= x <= 9:
		print((x - 1) * 10 + 1)
	if 11 <= x <= 99:
		x = x % 10
		print((x - 1) * 10 + 3)
	if 111 <= x <= 999:
		x = x % 10
		print((x - 1) * 10 + 6)
	if 1111 <= x <= 9999:
		x = x % 10
		print(x * 10)


t = int(input())
for _ in range(t):
	s = input()
	l = len(s)
	n = int(s[0])
	first = (n - 1) * 10
	second = l * (l + 1) // 2
	print(first + second)


t = int(input())
for _ in range(t):
	n = int(input())
	i = 1
	c = (n % 10 - 1) * 10
	while n > 0:
		c += i
		i += 1
		n //= 10
	print(c)


t = int(input())
for i in range(t):
	x = int(input())
	ts = 1
	k = 0
	taps = 0
	while str(ts) * k != str(x):
		k += 1
		if k == 5:
			k = 1
			ts += 1
		taps += k
	print(taps)


t = int(input())
l = []
for i in range(0, t):
	n = input()
	l.append(n)
for j in range(0, t):
	b = int(l[j][0])
	num = b - 1
	k = len(l[j])
	n1 = k * (k + 1) / 2
	n2 = num * 10
	print(int(n1 + n2))


for t in range(int(input())):
	n = int(input())
	ans = 10 * (n % 10 - 1)
	ans += sum([x for x in range(len(str(n)) + 1)])
	print(ans)


t = int(input())
for i in range(t):
	x = int(input())
	x = str(x)
	(count, c) = (0, 1)
	for j in range(len(x)):
		count += c
		c += 1
	print(10 * (int(x[0]) - 1) + count)


for _ in range(int(input())):
	n = int(input())
	ans = 0
	flag = 0
	for i in range(1, 10):
		for j in [1, 2, 3, 4]:
			s = int(str(i) * j)
			ans += j
			if s == n:
				flag = 1
				break
		if flag:
			break
	print(ans)


t = int(input(''))
arr = [1, 3, 6, 10]
for _ in range(t):
	x = input('')
	decimal_position = len(x) - 1
	floor_position = int(x[0]) - 1
	o = floor_position * 10 + arr[decimal_position]
	print(o)


for _ in range(int(input())):
	c = input()
	l = len(c)
	s = int(c[0])
	print(10 * (s - 1) + 1 * (l == 1) + 3 * (l == 2) + 6 * (l == 3) + 10 * (l == 4))


n = int(input())
for i in range(n):
	text = input()
	k = int(text)
	arr = [0, 1, 3, 6, 10]
	print((k % 10 - 1) * 10 + arr[len(text)])


t = int(input())
for x in range(t):
	l = []
	for d in range(1, 10):
		for x in range(1, 5):
			s = ''
			for y in range(0, x):
				s = s + str(d)
			l.append(int(s))
	n = int(input())
	ans = 0
	for x in l:
		p = str(x)
		if x == n:
			ans += len(p)
			break
		else:
			ans += len(p)
	print(ans)


rem = [1, 3, 6, 10]
sol = []
n = int(input())
for i in range(n):
	num = list(input())
	sol.append(10 * (int(num[-1]) - 1) + rem[len(num) - 1])
for ans in sol:
	print(ans)


test = int(input())
while test > 0:
	n = int(input())
	it = n % 10
	i = 1
	ans = 0
	while i != it:
		ans += 10
		i += 1
	if len(str(n)) == 1:
		ans += 1
	elif len(str(n)) == 2:
		ans += 3
	elif len(str(n)) == 3:
		ans += 6
	elif len(str(n)) == 4:
		ans += 10
	print(ans)
	test -= 1


import sys
t = int(sys.stdin.readline())
sumdict = {1: 1, 2: 1 + 2, 3: 1 + 2 + 3, 4: 1 + 2 + 3 + 4}
for _ in range(t):
	num = int(sys.stdin.readline())
	if num in [1, 11, 111, 1111]:
		i = 1
	else:
		i = 9
		while i > 1:
			if str(num // i)[0] == '1':
				break
			i -= 1
	i -= 1
	k = len(str(num))
	out = i * 10 + sumdict[k]
	sys.__stdout__.write(str(out) + '\n')


t = int(input())
for i in range(t):
	n = int(input())
	a = str(n)
	f = int(a[0]) - 1
	ans = f * 10
	p = len(a)
	for j in range(1, p + 1):
		ans += j
	print(ans)


c = []
for i in range(1, 10):
	for j in range(1, 4 + 1):
		b = str(i) * j
		c.append(b)
for _ in range(int(input())):
	s = 0
	a = input()
	for i in c:
		s += len(i)
		if a == i:
			print(s)
			break


t = int(input())
while t:
	s = input()
	d = int(s[0])
	l = len(s)
	ans = 10 * (d - 1) + l * (l + 1) / 2
	print(int(ans))
	t -= 1


from collections import *
from itertools import *
from bisect import *

def inp():
	return int(input())

def arrinp():
	return [int(x) for x in input().split()]

def main():
	t = inp()
	for _ in range(t):
		x = input()
		dig = int(x) % 10
		ans = 10 * (dig - 1)
		for i in range(1, len(x) + 1):
			ans += i
		print(ans)
main()


t = int(input())
for _ in range(t):
	x = int(input())
	a = []
	for i in range(1, 10):
		sum = 0
		for j in range(0, 4):
			sum += 10 ** j * i
			a.append(sum)
	sum = 0
	i = 0
	j = 1
	while True:
		sum += j
		j += 1
		if j == 5:
			j = 1
		if a[i] == x:
			break
		i = i + 1
	print(sum)


ans = []
for t in range(int(input())):
	x = int(input())
	a = 10 * (x % 10 - 1)
	for i in range(1, len(str(x)) + 1):
		a += i
	ans += [a]
print(*ans, sep='\n')


t = int(input())
for i in range(t):
	s = input()
	l = len(s)
	a = int(s[0])
	ans = 0
	ans = (a - 1) * 10
	ans = ans + (l * l + l) / 2
	print(int(ans))
exit()


def ans(n):
	d = {1: 1, 2: 3, 3: 6, 4: 10}
	x = len(n)
	return (int(n[0]) - 1) * 10 + d[x]
T = int(input())
for i in range(T):
	n = input()
	print(ans(n))


for _ in range(int(input())):
	x = input()
	l = len(x)
	r = int(x[0])
	print(10 * (r - 1) + l * (l + 1) // 2)


t = int(input())
for _ in range(t):
	n = int(input())
	num = 0
	x = str(n)
	l = len(x)
	f = int(x[0])
	num += (f - 1) * 10
	if l == 1:
		num += 1
	elif l == 2:
		num += 3
	elif l == 3:
		num += 6
	elif l == 4:
		num += 10
	print(num)


import sys
t = int(input())
for i in range(t):
	n = input().strip()
	p = 0
	for j in range(1, int(n[0])):
		p = p + 10
	l = len(n)
	p = p + l * (l + 1) // 2
	print(p)


t = int(input())
for _ in range(t):
	n = input()
	m = int(n[0])
	temp = 4 - len(n)
	u1 = len(n) + 1
	s = 10 * (m - 1) + 10 - temp * (u1 + 4) // 2
	print(s)


q = int(input())
for i in range(0, q):
	n = input()
	o = int(n[0])
	s = 10 * (o - 1)
	if len(n) == 1:
		s = s + 1
	if len(n) == 2:
		s = s + 3
	if len(n) == 3:
		s = s + 6
	if len(n) == 4:
		s = s + 10
	print(s)


t = int(input())
for y_qtr in range(t):
	n = int(input())
	a = n % 10
	b = 0
	s = 0
	while n != 0:
		n = n // 10
		b = b + 1
	while b > 0:
		s = b + s
		b = b - 1
	print((a - 1) * 10 + s)


t = int(input())
for i in range(t):
	s = input()
	s1 = int(s)
	m = (int(s[0]) - 1) * 10
	for j in range(len(s)):
		m = m + j + 1
	print(m)


import sys
magic_num = 1 + 2 + 3 + 4

def solve(num: str) -> int:
	digit = int(num) % 10
	result = 0
	if digit != 1:
		result += magic_num * (digit - 1)
	num_length = len(num)
	if num_length == 1:
		result += 1
	elif num_length == 2:
		result += 3
	elif num_length == 3:
		result += 6
	else:
		result += magic_num
	return result
for (count, line) in enumerate(sys.stdin):
	if count == 0:
		continue
	print(solve(line.rstrip()))


for t in range(int(input())):
	x = int(input())
	ans = 0
	for i in range(1, 10):
		for j in range(1, 5):
			v = int(str(i) * j)
			ans += j
			if v == x:
				x = -1
				break
		if x < 0:
			break
	print(ans)


case = int(input())
for i in range(case):
	boaring = int(input())
	boar = list(str(boaring))
	first = int(boar[0])
	length = len(boar)
	if length == 1:
		print((first - 1) * 10 + 1)
	elif length == 2:
		print((first - 1) * 10 + 3)
	elif length == 3:
		print((first - 1) * 10 + 6)
	else:
		print((first - 1) * 10 + 10)


n = input()
t = int(n)
l = []
for i in range(t):
	x = input()
	l.append(int(x))

def fun(x):
	n = len(str(x))
	return n * (n + 1) // 2
for x in l:
	print(10 * (x % 10 - 1) + fun(x))


n = int(input())
for i in range(n):
	num = input()
	s = num[0]
	digit = len(num)
	if digit == 2:
		print(int(s) * 10 - 7)
	elif digit == 3:
		print(int(s) * 10 - 4)
	elif digit == 4:
		print(int(s) * 10)
	else:
		print(int(s) * 10 - 9)


b = [str(i) for i in range(1, 10001)]
b.sort()
b = [bi for bi in b if len(set(bi)) == 1]
cnts = [0] * 100
for i in range(len(b)):
	cnts[i] = len(b[i]) + cnts[i - 1]
from bisect import bisect_left
t = int(input())
for _ in range(t):
	x = input()
	i = bisect_left(b, x)
	print(cnts[i])


t = int(input())
while t:
	n = int(input())
	p = str(n)
	s = int(p[-1])
	q = len(str(n))
	ans = 10 * (s - 1)
	if q == 4:
		print(ans + 10)
	elif q == 3:
		print(ans + 6)
	elif q == 2:
		print(ans + 3)
	else:
		print(ans + 1)
	t -= 1


n = int(input())
for i in range(n):
	k = input()
	ans = (int(k[0]) - 1) * 10 + sum([i for i in range(1, len(k) + 1)])
	print(ans)


t = int(input())
for i in range(t):
	x = int(input())
	l = []
	q = int(str(x)[0])
	if x == 1:
		l.append(1)
	elif x == 11:
		l.append(1)
		l.append(11)
	elif x == 111:
		l.append(1)
		l.append(11)
		l.append(111)
	elif x == 1111:
		l.append(1)
		l.append(11)
		l.append(111)
		l.append(1111)
	for i in range(1, q):
		l.append(i * 1)
		l.append(i * 11)
		l.append(i * 111)
		l.append(i * 1111)
		if len(str(x)) == 1:
			l.append(x)
		elif len(str(x)) == 2:
			l.append(1 * q)
			l.append(11 * q)
		elif len(str(x)) == 3:
			l.append(1 * q)
			l.append(11 * q)
			l.append(111 * q)
		elif len(str(x)) == 4:
			l.append(1 * q)
			l.append(11 * q)
			l.append(111 * q)
			l.append(1111 * q)
	k = list(set(l))
	nl = []
	for i in k:
		nl.append(str(i))
	digit = []
	for i in nl:
		digit.append(len(i))
	sum = 0
	for i in digit:
		sum += i
	print(sum)


n = int(input())
for i in range(n):
	inputer = int(input())
	stand = inputer % 10
	summer = (stand - 1) * 10
	str1 = len(str(inputer))
	summer += str1 * (str1 + 1) // 2
	print(summer)


t = int(input())
for i in range(0, t):
	count = 0
	n = int(input())
	a = n
	while n != 0:
		n = n // 10
		count += 1
	p = a % 10
	j = (p - 1) * 10
	if count == 4:
		print(j + 10)
	elif count == 3:
		print(j + 6)
	elif count == 2:
		print(j + 3)
	else:
		print(j + 1)


tc = int(input())
for i in range(tc):
	a = int(input())
	l = list(str(a))
	lnt = len(l)
	digit = int(l[0])
	t1 = 10 * (digit - 1)
	t2 = lnt * (lnt + 1) / 2
	ans = t1 + t2
	print(int(ans))


for _ in range(int(input())):
	n = int(input())
	l = []
	(ans, c) = (0, 0)
	for i in range(1, 10):
		for j in range(1, 7):
			s = str(i) * j
			if int(s) <= 10000:
				c += j
				l.append((s, c))
	for i in l:
		if int(i[0]) == n:
			print(i[1])
			break


tc = int(input())
for case in range(tc):
	x = input()
	result = (int(x[0]) - 1) * 10
	for i in range(0, len(x)):
		result += i + 1
	print(result)


t = int(input())
for _ in range(t):
	n = int(input())
	print((n % 10 - 1) * 10 + sum(list(range(1, len(str(n)) + 1))))


import sys, math, collections, itertools
from collections import defaultdict
from functools import reduce

def file():
	sys.stdin = open('input.py', 'r')
	sys.stdout = open('output.py', 'w')

def get_array():
	l = list(map(int, input().split()))
	return l

def get_ints():
	return map(int, input().split())

def sod(n):
	(n, c) = (str(n), 0)
	for i in n:
		c += int(i)
	return c

def isPrime(n):
	if n <= 1:
		return False
	if n <= 3:
		return True
	if n % 2 == 0 or n % 3 == 0:
		return False
	i = 5
	while i * i <= n:
		if n % i == 0 or n % (i + 2) == 0:
			return False
		i = i + 6
	return True

def getFloor(A, x):
	(left, right) = (0, len(A) - 1)
	floor = -1
	while left <= right:
		mid = (left + right) // 2
		if A[mid] == x:
			return A[mid]
		elif x < A[mid]:
			right = mid - 1
		else:
			floor = A[mid]
			left = mid + 1
	return floor

def gcd(a, b):
	if b == 0:
		return a
	return gcd(b, a % b)

def chk_power_of_2(n):
	return n & n - 1 == 0

def factors(n):
	return set(reduce(list.__add__, ([i, n // i] for i in range(1, int(n ** 0.5) + 1) if n % i == 0)))

def main():
	for tt in range(int(input())):
		l = [1, 11, 111, 1111, 2, 22, 222, 2222, 3, 33, 333, 3333, 4, 44, 444, 4444, 5, 55, 555, 5555, 6, 66, 666, 6666, 7, 77, 777, 7777, 8, 88, 888, 8888, 9, 99, 999, 9999]
		n = int(input())
		c = 0
		for i in l:
			if i == n:
				c += len(str(i))
				break
			else:
				c += len(str(i))
		print(c)
main()


t = int(input())
for _ in range(t):
	x = int(input())
	extra = len(str(x))
	while x >= 10:
		x //= 10
	print(10 * (x - 1) + extra * (extra + 1) // 2)


a = int(input())
for i in range(a):
	c = input()
	d = c[0]
	ans = 0
	ans += 10 * (int(d) - 1)
	n = len(c)
	ans += n * (n + 1) / 2
	print(int(ans))


t = int(input())
kv = []
for i in range(t):
	n = int(input())
	STR = list(str(n))
	click = 0
	x = 1
	while x != int(STR[0]):
		if x != int(STR[0]):
			x += 1
			click += 10
	for i in range(len(STR)):
		click += 1 + i
	kv.append(click)
for i in range(t):
	print(kv[i])


for _ in range(int(input())):
	x = input()
	n = len(x)
	if x[0] == '1':
		print(n * (n + 1) // 2)
	else:
		print((int(x[0]) - 1) * 10 + n * (n + 1) // 2)


for _ in range(int(input())):
	x = input()
	call = int(x[0])
	answer = 0
	for i in range(1, call):
		answer += 10
	for i in range(1, len(x) + 1):
		answer += i
	print(answer)


t = int(input())
for _ in range(t):
	n = int(input())
	d = n % 10
	ans = d * 10 - 10
	if n % 10 == d:
		ans += 1
		n //= 10
	if n % 10 == d:
		ans += 2
		n //= 10
	if n % 10 == d:
		ans += 3
		n //= 10
	if n % 10 == d:
		ans += 4
		n //= 10
	print(ans)


test_cases = int(input())
results = []
for i in range(test_cases):
	boring_numbers = []
	number = ''
	repeat = 1
	digit = 1
	while True:
		for i in range(repeat):
			number += str(digit)
		repeat += 1
		if int(number) < 10000:
			boring_numbers.append(number)
		else:
			digit += 1
			repeat = 1
			if digit > 9:
				break
		number = ''
	room_number = input()
	total = 0
	for room in boring_numbers:
		total += len(room)
		if room == room_number:
			break
	results.append(total)
for result in results:
	print(result)


for i in range(int(input())):
	a = input()
	b = 0
	d = 0
	while b < len(a):
		b += 1
		d += b
	print(10 * (int(a[0]) - 1) + d)


d = [1, 3, 6, 10]
for i in range(int(input())):
	x = int(input())
	ans = 0
	ans += (x % 10 - 1) * 10
	r = len(str(x))
	ans += d[r - 1]
	print(ans)


try:
	t = int(input())
	while t:
		n = int(input())
		temp1 = n % 10
		temp2 = 0
		while n != 0:
			n = n // 10
			temp2 += 1
		temp3 = 0
		temp3 = temp1 * 10
		if temp2 == 1:
			temp3 -= 9
		elif temp2 == 2:
			temp3 -= 7
		elif temp2 == 3:
			temp3 -= 4
		print(temp3)
		t -= 1
except:
	pass


getn = lambda : int(input())
getlist = lambda : list(map(int, input().split(' ')))

def solve():
	X = getn()
	X_str = str(X)
	D = int(X_str[0])
	N = len(X_str)
	return 10 * (D - 1) + N * (N + 1) // 2
T = getn()
while T > 0:
	print(solve())
	T -= 1


t = int(input())
characters = ['1', '2', '3', '4', '5', '6', '7', '8', '9']
for _ in range(t):
	n = int(input())
	keysPressed = 0
	done = False
	for i in range(9):
		for j in range(1, 5):
			keysPressed += j
			if int(characters[i] * j) == n:
				done = True
				break
		if done == True:
			break
	print(keysPressed)


def solve(p):
	d = {1: 1, 2: 3, 3: 6, 4: 10}
	(l, p) = (len(p), int(p[:1]))
	if l == 1 == p:
		print(1)
	elif l == 4:
		print(p * d[l])
	else:
		n = str(p - 1) + str(d[l])
		print(int(n))
for _ in range(int(input())):
	p = input()
	solve(p)


from collections import deque
from math import ceil, sqrt
import sys
for _ in range(int(input())):
	x = int(input())
	ans = (x % 10 - 1) * 10 + 1
	if x > 10:
		ans += 2
	if x > 100:
		ans += 3
	if x > 1000:
		ans += 4
	print(ans)


n = int(input())
for i in range(n):
	a = int(input())
	s = 0
	for i in range(str(a).count(str(a % 10)) + 1):
		s += i
	print((a % 10 - 1) * 10 + s)


import math
from collections import defaultdict
import functools as f
from itertools import permutations as p
t = 1
t = int(input())
for _ in range(t):
	n = str(input())
	val = n[0]
	val = int(val)
	ans = 10 * (val - 1)
	le = len(n)
	ans += le * (le + 1) // 2
	print(ans)


casos = int(input())
for i in range(casos):
	numAct = '1'
	firtsVal = 1
	counter = 0
	boring = input()
	found = False
	while found != True:
		if boring == numAct:
			found = True
			counter += len(numAct)
		else:
			found = False
			counter += len(numAct)
			if len(numAct) == 4:
				firtsVal += 1
				numAct = str(firtsVal)
			else:
				numAct += str(firtsVal)
	print(counter)


import sys, math
import io, os

def data():
	return sys.stdin.readline().strip()

def mdata():
	return list(map(int, data().split()))

def outl(var):
	sys.stdout.write(' '.join(map(str, var)) + '\n')

def out(var):
	sys.stdout.write(str(var) + '\n')
mod = int(1000000000.0) + 7
for t in range(int(data())):
	s = data()
	ans = 10 * int(s[0]) - 10 + len(s) * (len(s) + 1) // 2
	out(ans)


def ch(s, r):
	st = ''.join(s)
	st = int(st)
	return st
for _ in range(int(input())):
	n = input()
	st = int(n[0])
	n = int(n)
	if n == 1:
		print(1)
		continue
	if st == 1:
		cr = 1
		cnt = 0
		for i in range(1, n):
			cr = ['1'] * i
			cr = ch(cr, i)
			if cr > n:
				break
			cnt += i
		print(cnt)
	elif st == 2:
		ar = [2]
		cnt = 10
		for i in range(1, n):
			cr = ['2'] * i
			cr = ch(cr, i)
			if cr > n:
				break
			cnt += i
		print(cnt)
	elif st == 3:
		cnt = 20
		for i in range(1, n):
			cr = ['3'] * i
			cr = ch(cr, i)
			if cr > n:
				break
			cnt += i
		print(cnt)
	elif st == 4:
		ar = ['4']
		cnt = 30
		for i in range(1, n):
			cr = ['4'] * i
			cr = ch(cr, i)
			if cr > n:
				break
			cnt += i
		print(cnt)
	elif st == 5:
		ar = [5]
		cnt = 40
		for i in range(1, n):
			cr = ['5'] * i
			cr = ch(cr, i)
			if cr > n:
				break
			cnt += i
		print(cnt)
	elif st == 6:
		ar = [6]
		cnt = 50
		for i in range(1, n):
			cr = ['6'] * i
			cr = ch(cr, i)
			if cr > n:
				break
			cnt += i
		print(cnt)
	elif st == 7:
		ar = [7]
		cnt = 60
		for i in range(1, n):
			cr = ['7'] * i
			cr = ch(cr, i)
			if cr > n:
				break
			cnt += i
		print(cnt)
	elif st == 8:
		ar = [8]
		cnt = 70
		for i in range(1, n):
			cr = ['8'] * i
			cr = ch(cr, i)
			if cr > n:
				break
			cnt += i
		print(cnt)
	elif st == 9:
		ar = [9]
		cnt = 80
		for i in range(1, n):
			cr = ['9'] * i
			cr = ch(cr, i)
			if cr > n:
				break
			cnt += i
		print(cnt)


t = int(input())
for i in range(t):
	n = int(input())
	lenn = 0
	chislo = 0
	if n // 1000 > 0:
		chislo += n / 1111
		lenn += 10
	elif n // 100 > 0:
		chislo += n / 111
		lenn += 6
	elif n // 10 > 0:
		chislo += n / 11
		lenn += 3
	else:
		chislo = n
		lenn += 1
	lenn += (chislo - 1) * 10
	print(int(lenn))


for _ in range(int(input())):
	n = int(input())
	l = n % 10
	if n == 0:
		print(0)
	elif n == 1:
		print(1)
	else:
		val = 10
		val = val * l
		s = str(n)
		lenght = len(s)
		if lenght == 4:
			print(val)
		elif lenght == 3:
			print(val - 4)
		elif lenght == 2:
			print(val - 4 - 3)
		else:
			print(val - 4 - 3 - 2)


l = {1: 1, 2: 3, 3: 6, 4: 10}
for _ in range(int(input())):
	n = input()
	a = int(n[0]) - 1
	ans = 10 * a + l[len(n)]
	print(ans)


import sys
import math
import bisect
from sys import stdin, stdout
from math import floor, sqrt, log
from collections import defaultdict as dd
from bisect import bisect_left as bl, bisect_right as br
mod = 1000000007

def gcd(a, b):
	while b:
		(a, b) = (b, a % b)
	return a

def mod_inverse(a, n):
	N = n
	xx = 0
	yy = 1
	y = 0
	x = 1
	while n > 0:
		q = a // n
		t = n
		n = a % n
		a = t
		t = xx
		xx = x - q * xx
		x = t
		t = yy
		yy = y - q * yy
		y = t
	x %= N
	x += N
	x %= N
	return x

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 * 2, n + 1, p):
				prime[i] = False
		p += 1
	prime[0] = False
	prime[1] = False
	return prime

def solve():
	l1 = [1, 11, 111, 1111, 2, 22, 222, 2222, 3, 33, 333, 3333, 4, 44, 444, 4444, 5, 55, 555, 5555, 6, 66, 666, 6666, 7, 77, 777, 7777, 8, 88, 888, 8888, 9, 99, 999, 9999]
	l2 = [1, 2, 3, 4, 1, 2, 3, 4, 1, 2, 3, 4, 1, 2, 3, 4, 1, 2, 3, 4, 1, 2, 3, 4, 1, 2, 3, 4, 1, 2, 3, 4, 1, 2, 3, 4]
	x = int(input())
	cnt = 0
	for i in range(len(l1)):
		if l1[i] == x:
			cnt += l2[i]
			break
		else:
			cnt += l2[i]
	print(cnt)
testcase = int(sys.stdin.readline())
for _ in range(testcase):
	solve()


def solve(a):
	cnt = 0
	for i in range(1, 10):
		n = 0
		for j in range(10):
			n += i * 10 ** j
			if n > 10000:
				break
			cnt += j + 1
			if n == a:
				return cnt
	return cnt
T = int(input())
for _ in range(T):
	print(solve(int(input())))


for tc in range(int(input())):
	n = input()
	ans = 0
	if '1' in n:
		for x in range(len(n), 0, -1):
			ans += x
		print(ans)
	else:
		temp = n[0]
		ans += (int(temp) - 1) * 10
		for x in range(len(n), 0, -1):
			ans += x
		print(ans)


from bisect import bisect_left as bl
from bisect import bisect_right as br
from heapq import heappush, heappop
import math
from collections import *
from functools import reduce, cmp_to_key
import sys
input = sys.stdin.readline
M = mod = 998244353

def factors(n):
	return sorted(set(reduce(list.__add__, ([i, n // i] for i in range(1, int(n ** 0.5) + 1) if n % i == 0))))

def inv_mod(n):
	return pow(n, mod - 2, mod)

def li():
	return [int(i) for i in input().rstrip('\n').split()]

def st():
	return input().rstrip('\n')

def val():
	return int(input().rstrip('\n'))

def li2():
	return [i for i in input().rstrip('\n')]

def li3():
	return [int(i) for i in input().rstrip('\n')]
for _ in range(val()):
	x = li3()
	if len(x) == 1:
		ans = 1
	if len(x) == 2:
		ans = 3
	if len(x) == 3:
		ans = 6
	if len(x) == 4:
		ans = 10
	print(10 * (max(x) - 1) + ans)


N = int(input())
testCase = []
for n in range(N):
	testCase.append(int(input()))
for tc in testCase:
	nb = 0
	for k in range(1, 10):
		i = ''
		for j in range(4):
			i += str(k)
			nb += len(i)
			if int(i) == tc:
				print(nb)
				break


def permute(boring):
	cur = 0
	for i in range(1, 10):
		cur = 0
		while True:
			cur = cur * 10 + i
			if cur > 10000:
				break
			boring.append(cur)
boring = []
permute(boring)
N = int(input())
for i in range(N):
	digits = [1, 3, 6, 10]
	cur = boring.index(int(input()))
	print(cur // 4 * 10 + digits[cur % 4])


t = int(input())
cnm = [0, 1, 3, 6, 10]
for _ in range(t):
	n = int(input())
	print((n % 10 - 1) * 10 + cnm[len(str(n))])


for s in [*open(0)][1:]:
	k = len(s)
	print(10 * (int(s[0]) - 1) + k * (k - 1) // 2)


from sys import stdin
t = int(stdin.readline().strip())

def sum(x):
	return x * (x + 1) // 2
for _ in range(t):
	x = stdin.readline().strip()
	total = sum(len(x)) + 10 * (int(x[0]) - 1)
	print(total)


t = int(input())
for _ in range(t):
	str_ = input()
	n = int(str_[0]) - 1
	s = len(str_)
	print(n * (1 + 2 + 3 + 4) + s * (s + 1) // 2)


def boring(s):
	l = len(s)
	return l * (l + 1) // 2 + (int(s[0]) - 1) * 10
for _ in range(int(input())):
	print(boring(input()))


def read_generator():
	while True:
		tokens = input().split(' ')
		for t in tokens:
			yield t
reader = read_generator()

def readword():
	return next(reader)

def readint():
	return int(next(reader))

def readfloat():
	return float(next(reader))

def readline():
	return input()

def solve(n):
	k = 0
	for i in range(1, 10):
		for j in range(1, 5):
			k += j
			if n == str(i) * j:
				return k
tests = readint()
for t in range(tests):
	print(solve(readword()))


def ans2(x):
	ret = 0
	for i in range(x + 1):
		ret += i
	return ret

def ans(x):
	d = int(str(x)[0])
	return (d - 1) * 10 + ans2(len(str(x)))
for _ in range(int(input())):
	x = int(input())
	print(ans(x))


t = int(input())
for i in range(t):
	a = input()
	ans = (int(a[0]) - 1) * 10
	n = len(a)
	while n != 0:
		ans += n
		n -= 1
	print(ans)


t = int(input())

def get_sum(x):
	return (x + 1) * x / 2
for _ in range(t):
	num = input()
	dig = int(num[0])
	print('%d' % (get_sum(len(num)) + 10 * (dig - 1)))


for _ in range(int(input())):
	n = input()
	a = [str(i) * j for i in range(1, 10) for j in range(1, 5)]
	i = a.index(n)
	cnt = 0
	for j in range(1, i + 1):
		cnt += 1 + j % 4
	print(cnt + 1)


for _ in range(int(input())):
	n = int(input())
	digit = 0
	repeat = n % 10
	while n > 0:
		n //= 10
		digit += 1
	print((repeat - 1) * 10 + digit * (digit + 1) // 2)


import os
from io import BytesIO, IOBase
import sys
from collections import defaultdict, deque, Counter
from bisect import *
from math import sqrt, pi, ceil
import math
from itertools import permutations
from copy import deepcopy
from sys import setrecursionlimit

def main():
	for t in range(int(input())):
		x = int(input())
		j = 1
		c = 0
		while j <= 9:
			i = j
			f = 0
			while i <= 9999:
				c += len(str(i))
				if i == x:
					f = 1
					break
				i = i * 10 + j
			if f:
				break
			j += 1
		print(c)
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
input = lambda : sys.stdin.readline().rstrip('\r\n')
main()


for _ in range(int(input())):
	n = int(input())
	a = []
	b = []
	for i in range(1, 10):
		for j in range(1, 5):
			a.append(int(str(i) * j))
			if len(a) == 1:
				b.append(1)
			else:
				b.append(b[-1] + j)
	print(b[a.index(n)])


a = []
for i in range(1, 10):
	a.append(str(i))
	a.append(str(i) * 2)
	a.append(str(i) * 3)
	a.append(str(i) * 4)
b = []
for i in a:
	b.append(int(i))
x = int(input())
inp = []
for i in range(0, x):
	c = int(input())
	inp.append(c)
for j in inp:
	for i in range(0, len(b)):
		if j == b[i]:
			t = i + 1
			if (i + 1) % 4 == 0:
				print(t // 4 * 10 + 0)
			if (i + 1) % 4 == 1:
				print(t // 4 * 10 + 1)
			if (i + 1) % 4 == 2:
				print(t // 4 * 10 + 3)
			if (i + 1) % 4 == 3:
				print(t // 4 * 10 + 6)


for i1 in range(int(input())):
	n = int(input())
	lim = n % 10
	ans = (lim - 1) * 10
	s = str(n)
	ans += len(s) * (len(s) + 1) // 2
	print(ans)


S = open(0).read().split()
for n in S[1:]:
	(n, ans) = (int(n), 0)
	for i in range(1, 10):
		j = 0
		f = False
		for k in range(4):
			j = j * 10 + i
			ans += k + 1
			if j == n:
				f = True
				break
		if f:
			break
	print(ans)


for i in range(int(input())):
	y = int(input())
	u = int(str(y)[0])
	L = len(str(y))
	if L == 1:
		t = 1
	elif L == 2:
		t = 3
	elif L == 3:
		t = 6
	else:
		t = 10
	print((u - 1) * 10 + t)


def proA(x):
	ans = 0
	for i in range(1, 10):
		st = str(i)
		while len(st) <= 4:
			if str(x) == st:
				ans += len(st)
				return ans
			ans += len(st)
			st += str(i)
t = int(input())
for i in range(t):
	n = int(input())
	print(proA(n))


import sys, collections
dp = []
for i in range(1, 10):
	for j in range(1, 5):
		dp.append(str(i) * j)
n = int(sys.stdin.readline())
for _ in range(n):
	temp = sys.stdin.readline().rstrip()
	ans = 0
	for i in dp:
		ans += len(i)
		if i == temp:
			break
	print(ans)


for _ in range(int(input())):
	n = input()
	n1 = int(n[0]) - 1
	s = n1 * 10
	for i in range(1, len(n) + 1):
		s += i
	print(s)


for t in range(int(input())):
	x = str(input())
	res = 0
	if x[0] == '1':
		if len(x) == 1:
			res = 1
		elif len(x) == 2:
			res = 3
		elif len(x) == 3:
			res = 6
		elif len(x) == 4:
			res = 10
	else:
		if len(x) == 1:
			res = 1
		elif len(x) == 2:
			res = 3
		elif len(x) == 3:
			res = 6
		elif len(x) == 4:
			res = 10
		res += (int(x[0]) - 1) * 10
	print(res)


n = input()
input_cases = []
for case in range(int(n)):
	input_cases.append(input())
for num in input_cases:
	number = (int(num[0]) - 1) * 10
	for i in range(len(num) + 1):
		number += i
	print(number)


n = int(input())
for i in range(n):
	x = input()
	fl = int(x[0])
	ans = (fl - 1) * 10 + sum(range(1, len(x) + 1))
	print(ans)


t = 1
t = int(input())
while t:
	t -= 1
	x = int(input())
	len_ = len(str(x))
	before = (int(str(x)[0]) - 1) * 10
	for i in range(1, len_ + 1):
		before += i
	print(before)


t = int(input())
while t > 0:
	t -= 1
	r = str(input())
	ans = ''
	found = False
	for i in range(1, 10):
		for j in range(1, 5):
			idx = ''.join([str(i)] * j)
			ans = ans + idx
			if idx == r:
				print(len(ans))
				found = True
				break
		if found is True:
			break


for _ in range(int(input())):
	x = int(input())
	s = str(x)
	ans = 10 * (int(s[0]) - 1)
	ans += len(s) * (len(s) + 1) // 2
	print(ans)


for i in range(int(input())):
	a = int(input())
	if a % 1111 == 0:
		print(a // 1111 * 10)
	elif a % 111 == 0:
		print(a // 111 * 10 - 4)
	elif a % 11 == 0:
		print(a // 11 * 10 - 7)
	else:
		print(a * 10 - 9)


import sys, os
from math import sqrt, gcd, ceil, log, floor
from bisect import bisect, bisect_left
from collections import defaultdict, Counter, deque
from heapq import heapify, heappush, heappop
input = sys.stdin.readline
read = lambda : list(map(int, input().strip().split()))
MOD = 10 ** 9 + 7

def main():
	for _ in range(int(input())):
		n = input().strip()
		x = (int(n[0]) - 1) * 10 + len(n) * (len(n) + 1) // 2
		print(x)
main()


l = []
for i in range(int(input())):
	z = 0
	x = int(input())
	f = x % 10
	for j in range(1, len(str(x)) + 1):
		z = z + j
	l.append(10 * (f - 1) + z)
print(*l, sep='\n')


n = int(input())
while n:
	n = n - 1
	x = input()
	a = int(x[0])
	b = len(x)
	s = (a - 1) * 10 + int(b * (b + 1) / 2)
	print(s)


a = int(input())
i = 1
while i < a + 1:
	i = i + 1
	b = int(input())
	n = 1
	x = 0
	b = str(b)
	while n < int(b[0]):
		x = x + 10
		n = n + 1
	if len(b) == 1:
		x = x + 1
	if len(b) == 2:
		x = x + 3
	if len(b) == 3:
		x = x + 6
	if len(b) == 4:
		x = x + 10
	print(x)


def solve(n):
	length = str(n)
	unit_digit = int(length[0])
	length = len(length)
	s = 0
	if unit_digit == 1:
		for i in range(1, length + 1):
			s += i
		return s
	s = 0
	for i in range(unit_digit - 1):
		s += 10
	for i in range(1, length + 1):
		s += i
	return s
for i in range(int(input())):
	n = int(input())
	print(solve(n))


for _ in range(int(input())):
	d = {}
	d[1] = 1
	d[2] = 3
	d[3] = 6
	d[4] = 10
	n = input()
	p = len(n)
	c = 10 * (int(n[0]) - 1) + d[p]
	print(c)


def function(num):
	answer = 0
	for i in range(1, 10):
		k = i
		for j in range(1, 5):
			answer += j
			if k == num:
				print(answer)
			k = k * 10 + i
for g in range(int(input())):
	function(int(input()))


for t in range(int(input())):
	n = int(input())
	a = n % 10 - 1
	b = 0
	while n > 0:
		n //= 10
		b += 1
	out = a * 10
	for i in range(1, b + 1):
		out += i
	print(out)


t = int(input(''))
result_holder = []
for i in range(t):
	tasks = input('')
	count = 0
	for k in range(int(tasks[-1])):
		for j in range(1, 4 + 1):
			count += j
	p = 4
	if len(tasks) != 4:
		while len(tasks) != p:
			count -= p
			p -= 1
	result_holder.append(count)
for an in result_holder:
	print(an)


li = ['1', '11', '111', '1111', '2', '22', '222', '2222', '3', '33', '333', '3333', '4', '44', '444', '4444', '5', '55', '555', '5555', '6', '66', '666', '6666', '7', '77', '777', '7777', '8', '88', '888', '8888', '9', '99', '999', '9999']
t = int(input())
while t > 0:
	x = input()
	p = li.index(x)
	c = 0
	for i in range(p + 1):
		c = len(li[i]) + c
	print(c)
	t = t - 1


t = int(input())
for i in range(t):
	x = int(input())
	u = x // 10
	k = 0
	k += (x % 10 - 1) * 10
	if u <= 0:
		k += 1
	elif u // 10 <= 0:
		k += 3
	elif u // 100 <= 0:
		k += 6
	elif u // 1000 <= 0:
		k += 10
	print(k)


for _ in range(int(input())):
	x = int(input())
	c = 0
	for i in range(1, 10):
		k = i
		while i <= 10000:
			c += len(str(i))
			if i == x:
				break
			i *= 10
			i += k
		else:
			continue
		break
	print(c)


cal = int(input())
res = [input() for i in range(cal)]
sum = 0
for i in res:
	l = int(i[0])
	s = i
	while l != 0:
		if s != '':
			sum += len(s)
			s = s[:-1]
		else:
			l -= 1
			s = 4 * str(l)
	print(sum)
	sum = 0


ques = [1, 11, 111, 1111]
ans = []
for i in range(1, 10):
	ans += [i * j for j in ques]
lookup = [1, 3, 6, 10]
for _ in range(int(input())):
	n = int(input())
	ind = ans.index(n) + 1
	clicks = ind // 4 * 10
	look = ind % 4
	if look != 0:
		clicks += lookup[look - 1]
	print(clicks)


for _ in range(int(input())):
	s = input()
	n = int(s[0])
	print((n - 1) * 10 + [0, 1, 3, 6, 10][len(s)])


for i in range(int(input())):
	n = int(input())
	s = 0
	z = n
	while z != 0:
		m = z % 10
		s += 1
		z = z // 10
	if s == 4:
		print(n // 1000 * 10)
	elif s == 3:
		print(n // 100 * 10 - 4)
	elif s == 2:
		print(n // 10 * 10 - 7)
	elif s == 1:
		if n == 1:
			print('1')
		else:
			print((n - 1) * 10 + 1)


b = int(input())
for i in range(b):
	n = int(input())
	x = str(n)
	i = int(x[0])
	s = 0
	v = int(x[-1])
	if len(x) == 4:
		for i in range(v):
			i = (1 + 2 + 3 + 4) * v
			a = i
		print(i)
	elif len(x) == 3:
		for i in range(v):
			i = 10 * (v - 1) + 6
			a = i
		print(i)
	elif len(x) == 2:
		for i in range(v):
			i = 10 * (v - 1) + 3
			a = i
		print(i)
	elif len(x) == 1:
		for i in range(v):
			i = 10 * (v - 1) + 1
			a = i
		print(i)


base = [1, 11, 111, 1111]
pre = []
for num in range(1, 10):
	for b in base:
		pre.append(b * num)
for _ in range(int(input())):
	x = int(input())
	ans = 0
	for num in pre:
		if x == num:
			ans += len(str(num))
			break
		else:
			ans += len(str(num))
	print(ans)


t = int(input())

def solve():
	x = int(input())
	nums = []
	for i in range(1, 10):
		string = str(i)
		st1 = int(string)
		st2 = int(string + string)
		st3 = int(string + string + string)
		st4 = int(string + string + string + string)
		nums.append(st1)
		nums.append(st2)
		nums.append(st3)
		nums.append(st4)
	ans = 0
	for i in nums:
		ans += len(str(i))
		if i == x:
			break
	print(ans)
for i in range(t):
	solve()


for i in range(int(input())):
	lis = ['1', '11', '111', '1111', '2', '22', '222', '2222', '3', '33', '333', '3333', '4', '44', '444', '4444', '5', '55', '555', '5555', '6', '66', '666', '6666', '7', '77', '777', '7777', '8', '88', '888', '8888', '9', '99', '999', '9999']
	A = input()
	Str = ''
	indx = lis.index(str(A))
	ope = lis[:indx + 1]
	for j in ope:
		Str += j
	print(len(Str))


n = int(input())
d = []
for i in range(n):
	d.append(str(input()))
for i in range(n):
	print(int((int(d[i][0]) - 1) * 10 + len(d[i]) * (len(d[i]) + 1) / 2))


for i in range(int(input())):
	num = int(input())
	digit = num % 10
	print(10 * (digit - 1) + len(str(num)) * (len(str(num)) + 1) // 2)


from sys import stdin, stdout

def SI():
	return stdin.readline()[:-1]

def II():
	return int(stdin.readline())

def solve():
	sx = SI()
	ans = 0
	lx = len(sx)
	ix = int(sx[0])
	ans = 10 * (ix - 1)
	if lx == 1:
		ans += 1
	elif lx == 2:
		ans += 3
	elif lx == 3:
		ans += 6
	else:
		ans += 10
	stdout.write(str(ans) + '\n')
t = II()
for _ in range(t):
	solve()


n = int(input())
a = ['0'] * n
for i in range(n):
	a[i] = input()
s = [0] * n
for i in range(n):
	if a[i].find('1') != -1:
		if len(a[i]) == 4:
			s[i] = len(a[i]) + 6
		elif len(a[i]) == 3:
			s[i] = len(a[i]) + 3
		elif len(a[i]) == 2:
			s[i] = len(a[i]) + 1
		else:
			s[i] = len(a[i])
	elif a[i].find('2') != -1:
		if len(a[i]) == 4:
			s[i] = 10 + len(a[i]) + 6
		elif len(a[i]) == 3:
			s[i] = 10 + len(a[i]) + 3
		elif len(a[i]) == 2:
			s[i] = 10 + len(a[i]) + 1
		else:
			s[i] = 10 + len(a[i])
	elif a[i].find('3') != -1:
		if len(a[i]) == 4:
			s[i] = 20 + len(a[i]) + 6
		elif len(a[i]) == 3:
			s[i] = 20 + len(a[i]) + 3
		elif len(a[i]) == 2:
			s[i] = 20 + len(a[i]) + 1
		else:
			s[i] = 20 + len(a[i])
	elif a[i].find('4') != -1:
		if len(a[i]) == 4:
			s[i] = 30 + len(a[i]) + 6
		elif len(a[i]) == 3:
			s[i] = 30 + len(a[i]) + 3
		elif len(a[i]) == 2:
			s[i] = 30 + len(a[i]) + 1
		else:
			s[i] = 30 + len(a[i])
	elif a[i].find('5') != -1:
		if len(a[i]) == 4:
			s[i] = 40 + len(a[i]) + 6
		elif len(a[i]) == 3:
			s[i] = 40 + len(a[i]) + 3
		elif len(a[i]) == 2:
			s[i] = 40 + len(a[i]) + 1
		else:
			s[i] = 40 + len(a[i])
	elif a[i].find('6') != -1:
		if len(a[i]) == 4:
			s[i] = 50 + len(a[i]) + 6
		elif len(a[i]) == 3:
			s[i] = 50 + len(a[i]) + 3
		elif len(a[i]) == 2:
			s[i] = 50 + len(a[i]) + 1
		else:
			s[i] = 50 + len(a[i])
	elif a[i].find('7') != -1:
		if len(a[i]) == 4:
			s[i] = 60 + len(a[i]) + 6
		elif len(a[i]) == 3:
			s[i] = 60 + len(a[i]) + 3
		elif len(a[i]) == 2:
			s[i] = 60 + len(a[i]) + 1
		else:
			s[i] = 60 + len(a[i])
	elif a[i].find('8') != -1:
		if len(a[i]) == 4:
			s[i] = 70 + len(a[i]) + 6
		elif len(a[i]) == 3:
			s[i] = 70 + len(a[i]) + 3
		elif len(a[i]) == 2:
			s[i] = 70 + len(a[i]) + 1
		else:
			s[i] = 70 + len(a[i])
	elif a[i].find('9') != -1:
		if len(a[i]) == 4:
			s[i] = 80 + len(a[i]) + 6
		elif len(a[i]) == 3:
			s[i] = 80 + len(a[i]) + 3
		elif len(a[i]) == 2:
			s[i] = 80 + len(a[i]) + 1
		else:
			s[i] = 80 + len(a[i])
	print(s[i])


for i in range(int(input())):
	x = int(input())
	a = str(x)
	b = a[0]
	n = len(a)
	print((int(b) - 1) * 10 + n * (n + 1) // 2)


import math
from collections import deque
from sys import stdin, stdout, setrecursionlimit
from string import ascii_letters
letters = ascii_letters[:26]
from collections import defaultdict
input = stdin.readline
for _ in range(int(input())):
	x = int(input())
	res = 0
	for g in range(1, int(str(x)[0]) + 1):
		have = [str(g)]
		while int(''.join(have)) <= 10000:
			if g == int(str(x)[0]) and len(have) > len(str(x)):
				break
			res += len(have)
			have += [str(g)]
	print(res)


w = int(input())
for i in range(w):
	number = input()
	a = int(number[0])
	x = [1, 3, 6, 10]
	t = (a - 1) * x[-1] + x[len(number) - 1]
	print(t)


d = {1: 1, 2: 3, 3: 6, 4: 10}
for i in range(int(input())):
	n = input()
	s = int(n[0]) - 1
	l = len(n)
	n = int(n)
	print(s * 10 + d[l])


for _ in range(int(input())):
	x = int(input())
	digits = 0
	num = 0
	result = 0
	digit = x % 10
	while x:
		num += 1
		x = x // 10
	result += (digit - 1) * 10
	if num == 1:
		result += 1
	elif num == 2:
		result += 3
	elif num == 3:
		result += 6
	elif num == 4:
		result += 10
	print(result)


t = int(input())
for i in range(t):
	a = int(input())
	summ = (a % 10 - 1) * 10
	k = 0
	for j in range(len(str(a))):
		k += 1
		summ += k
	print(summ)


t = int(input())
for _ in range(t):
	n = input()
	num = len(n)
	n = int(n)
	s = ''
	for _ in range(num):
		s += str(1)
	s = int(s)
	p = n // s - 1
	total = p * 10
	total += num * (num + 1) // 2
	print(total)


def boring(cases):
	for apt in cases:
		if int(apt / 1000) > 0:
			print(int(apt / 1000) * 10)
		elif int(apt / 100) > 0:
			print((int(apt / 100) - 1) * 10 + 6)
		elif int(apt / 10) > 0:
			print((int(apt / 10) - 1) * 10 + 3)
		else:
			print((apt - 1) * 10 + 1)
num = int(input())
if num == 0 or num > 36:
	raise ValueError('The value was out of range')
cases = []
for i in range(num):
	apt = int(input())
	if apt < 1 or apt > 9999:
		raise ValueError('The value was out of range')
	cases.append(apt)
boring(cases)


try:
	T = int(input())
	for _ in range(T):
		x = int(input())
		digit = x % 10
		x_new = str(x)
		count = len(x_new)
		mul = (digit - 1) * 10
		add = 0
		for i in range(1, count + 1):
			add = add + i
		result = add + mul
		print(result)
except EOFError:
	pass


T = int(input())
for z in range(T):
	n = input()
	pn = int(n[0]) - 1
	out = 10 * pn
	N = len(n)
	out += N * (N + 1) // 2
	print(out)


for _ in range(int(input())):
	n = int(input())
	d = n % 10
	l = len(str(n))
	ans = (d - 1) * 10 + l * (l + 1) // 2
	print(ans)


for i in range(int(input())):
	n = int(input())
	c = 1
	while n // 10 != 0:
		c += 1
		n = n // 10
	print(c * (c + 1) // 2 + (n - 1) * 10)


t = int(input())
for i in range(t):
	n = input()
	n1 = len(n)
	r = int(n[0])
	s1 = 10 * (r - 1)
	ans = s1 + len(n) * (len(n) + 1) // 2
	print(ans)


n = int(input())
l1 = [1, 11, 111, 1111, 2, 22, 222, 2222, 3, 33, 333, 3333, 4, 44, 444, 4444, 5, 55, 555, 5555, 6, 66, 666, 6666, 7, 77, 777, 7777, 8, 88, 888, 8888, 9, 99, 999, 9999]
(l2, l3, l4) = ([], [], [])
sum = 0
for i in l1:
	l2.append(str(i))
for i in range(n):
	n1 = int(input())
	index = l1.index(n1)
	for i in range(0, index + 1):
		sum += int(len(l2[i]))
	l3.append(sum)
l4.append(l3[0])
for i in range(1, len(l3)):
	l4.append(l3[i] - l3[i - 1])
for i in l4:
	print(i)


t = int(input())
while t > 0:
	t -= 1
	st = str(input())
	x = st[0]
	x = int(x)
	s = 0
	s = 10 * (x - 1)
	n = len(st)
	if n == 1:
		s += 1
	elif n == 2:
		s += 3
	elif n == 3:
		s += 6
	elif n == 4:
		s += 10
	print(s)


import math
try:
	t = int(input())
	for i in range(t):
		s = int(input())
		p = s
		cp = 1
		while p // 10 > 0:
			p = p // 10
			cp += 1
		n = s % 10
		j = 1
		ans1 = 0
		while cp > 0:
			ans1 += j
			j += 1
			cp -= 1
		ans = (n - 1) * 10 + ans1
		print(ans)
except:
	pass


try:
	for _ in range(int(input())):
		f = input()
		l = len(f)
		val = int(f[0])
		ans = 10 * (val - 1)
		for i in range(1, l + 1):
			ans += i
		print(ans)
except:
	pass


vc = [str(i) for i in range(1, 10)]
v = []
for c in vc:
	for j in range(1, 5):
		v.append(int(j * c))
for q_ in range(int(input())):
	x = int(input())
	s = 0
	i = 0
	for i in range(len(v)):
		s += i % 4 + 1
		if v[i] == x:
			print(s)
			break
		i += 1


number_of_test_cases = int(input())
all_boring_numbers = [str(i) * j for i in range(1, 10) for j in range(1, 5)]
for i in range(number_of_test_cases):
	first_boring_apartment_number = input()
	keys_pressed = 0
	for boring_number in all_boring_numbers:
		keys_pressed += len(boring_number)
		if boring_number == first_boring_apartment_number:
			break
	print(keys_pressed)


t = int(input())
while t != 0:
	x = int(input())
	k = str(x)[0]
	net = ''
	for i in range(1, int(k)):
		y = ''
		for j in range(5):
			y += j * str(i)
		net += y
	z = str(x)
	for i in range(1, len(z) + 1):
		net += i * k
	print(len(net))
	t -= 1


t = int(input())
for i in range(t):
	x = int(input())
	ln = len(str(x))
	dig = x % 10 - 1
	print(int(dig * 10 + (1 + ln) * ln / 2))


t = int(input())
for _ in range(t):
	n = list(input())
	l = len(n)
	num = 10 * (int(n[0]) - 1)
	while l != 0:
		num += l
		l = l - 1
	print(num)


t = int(input())
for i in range(t):
	x = str(input())
	l = len(x)
	lls = [1, 3, 6, 10]
	r = int(x) % 10 * 10
	r -= 10
	r = r + lls[l - 1]
	print(r)


t = int(input())
for _ in range(t):
	x = int(input())
	haha = []
	count = 0
	result = []
	for i in range(1, 5):
		haha.append('1' * i)
	for i in range(1, 5):
		haha.append('2' * i)
	for i in range(1, 5):
		haha.append('3' * i)
	for i in range(1, 5):
		haha.append('4' * i)
	for i in range(1, 5):
		haha.append('5' * i)
	for i in range(1, 5):
		haha.append('6' * i)
	for i in range(1, 5):
		haha.append('7' * i)
	for i in range(1, 5):
		haha.append('8' * i)
	for i in range(1, 5):
		haha.append('9' * i)
	for i in haha:
		result.append(int(i))
	int1 = result.index(x)
	for i in range(0, int1 + 1):
		count += len(haha[i])
	print(count)


for _ in range(int(input())):
	s = input()
	n = int(s[0])
	nd = n - 1
	sum1 = nd * 10
	nd = len(s)
	for i in range(1, nd + 1):
		sum1 += i
	print(sum1)


t = int(input())
for i in range(t):
	line = input().strip()
	res = 0
	k = int(line[0])
	n = len(line)
	res += (k - 1) * 10
	res += (1 + n) * n // 2
	print(res)


import os
import sys
from io import BytesIO, IOBase
_str = str
BUFSIZE = 8192

def str(x=b''):
	return x if type(x) is bytes else _str(x).encode()

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')

def inp():
	return sys.stdin.readline().rstrip()

def mpint():
	return map(int, inp().split(' '))

def itg():
	return int(inp())
from itertools import accumulate

def solve():
	data = []
	for i in range(1, 10):
		s = _str(i)
		data.extend([s, s * 2, s * 3, s * 4])
	ans = tuple(accumulate(map(len, data)))
	for _ in range(itg()):
		print(ans[data.index(inp())])

def main():
	solve()
DEBUG = 0
URL = ''
if DEBUG == 1:
	import requests
	from ACgenerator.Y_Test_Case_Runner import TestCaseRunner
	runner = TestCaseRunner(main, URL)
	inp = runner.input_stream
	print = runner.output_stream
	runner.checking()
elif DEBUG == 2:
	main()
else:
	(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
	main()


t = int(input())
for _ in range(t):
	x = input()
	n = len(x)
	a = int(x[0])
	count = 0
	for i in range(a - 1):
		count += 10
	for i in range(1, n + 1):
		count += i
	print(count)


for _ in range(int(input())):
	num = input()
	curr = ''
	count = 0
	for i in range(1, int(num[0])):
		count += 10
	while curr != num:
		curr += num[0]
		count += len(curr)
	print(count)


n = int(input())
for i in range(n):
	n = str(input())
	x = (int(n[0]) - 1) * 10
	y = len(n) * (len(n) + 1) // 2
	print(x + y)


a = [0, 1, 3, 6, 10]
for _ in range(int(input())):
	n = input()
	l = len(n)
	f = int(n[0])
	f -= 1
	print(f * 10 + a[l])


import sys as _sys

def main():
	t = int(input())
	for i_t in range(t):
		x = _read_line()
		full_before = int(x[0]) - 1
		result = full_before * (1 + 2 + 3 + 4) + sum(range(1, len(x) + 1))
		print(result)

def _read_line():
	result = _sys.stdin.readline()
	assert result[-1] == '\n'
	return result[:-1]

def _read_ints():
	return map(int, _read_line().split())
main()


t = int(input())
for _ in range(t):
	n = int(input())
	a = str(n)
	x = int(a[0])
	ans = 0
	ans += (x - 1) * 10
	y = len(a)
	if y == 1:
		ans += 1
	elif y == 2:
		ans += 3
	elif y == 3:
		ans += 6
	else:
		ans += 10
	print(ans)


for _ in range(int(input())):
	n = input()
	s = int(n[0])
	an = (s - 1) * 10
	p = len(n)
	if p == 1:
		an += 1
	elif p == 2:
		an += 3
	elif p == 3:
		an += 6
	else:
		an += 10
	print(an)


for _ in range(int(input())):
	x = input()
	d = int(x[0])
	ans = (d - 1) * 10
	for i in range(len(x)):
		ans += i + 1
	print(ans)


from sys import stdin, stdout
from collections import defaultdict
input = stdin.readline
print = stdout.write
mylist = [1, 11, 111, 1111]
new_list = []
for i in range(1, 10):
	for item in mylist:
		new_list.append(str(i * item))
for _ in range(int(input())):
	myword = int(input())
	n = len(str(myword))
	myanswer = 10 * (myword % 10 - 1)
	myanswer += n * (n + 1) // 2
	print(str(myanswer) + '\n')


test_cases = int(input())
arr = [1, 3, 6, 10]
for t in range(test_cases):
	n = str(input())
	first = n[0]
	first = (int(first) - 1) * 10
	length = len(n)
	print(first + arr[length - 1])


for _ in range(int(input())):
	num = int(input())
	num1 = str(num)
	n = len(num1)
	if n == 1:
		print(10 * (num % 10 - 1) + 1)
	elif n == 2:
		print(10 * (num % 10 - 1) + 3)
	elif n == 3:
		print(10 * (num % 100 % 10 - 1) + 6)
	else:
		print(10 * (num % 1000 % 100 % 10 - 1) + 10)


def boringApartment(boringApartments, apartment):
	count = 0
	for k in boringApartments:
		if k != str(apartment):
			count += len(k)
		else:
			count += len(str(apartment))
			break
	return count
n = int(input())
boringApartments = []
for i in range(1, 10):
	a = ''
	for j in range(4):
		a += str(i)
		boringApartments.append(a)
for _ in range(n):
	apartment = int(input())
	print(boringApartment(boringApartments, apartment))


for _ in range(0, int(input())):
	s = int(input())
	b = list(str(s))
	a = [int(i) for i in b]
	if len(a) == 1:
		if a[0] == 1:
			print('1')
		elif a[0] == 2:
			print('11')
		elif a[0] == 3:
			print('21')
		elif a[0] == 4:
			print('31')
		elif a[0] == 5:
			print('41')
		elif a[0] == 6:
			print('51')
		elif a[0] == 7:
			print('61')
		elif a[0] == 8:
			print('71')
		elif a[0] == 9:
			print('81')
	elif len(a) == 2:
		if a[0] == 1:
			print('3')
		elif a[0] == 2:
			print('13')
		elif a[0] == 3:
			print('23')
		elif a[0] == 4:
			print('33')
		elif a[0] == 5:
			print('43')
		elif a[0] == 6:
			print('53')
		elif a[0] == 7:
			print('63')
		elif a[0] == 8:
			print('73')
		elif a[0] == 9:
			print('83')
	elif len(a) == 3:
		if a[0] == 1:
			print('6')
		elif a[0] == 2:
			print('16')
		elif a[0] == 3:
			print('26')
		elif a[0] == 4:
			print('36')
		elif a[0] == 5:
			print('46')
		elif a[0] == 6:
			print('56')
		elif a[0] == 7:
			print('66')
		elif a[0] == 8:
			print('76')
		elif a[0] == 9:
			print('86')
	elif a[0] == 1:
		print('10')
	elif a[0] == 2:
		print('20')
	elif a[0] == 3:
		print('30')
	elif a[0] == 4:
		print('40')
	elif a[0] == 5:
		print('50')
	elif a[0] == 6:
		print('60')
	elif a[0] == 7:
		print('70')
	elif a[0] == 8:
		print('80')
	elif a[0] == 9:
		print('90')


for efkjr in range(int(input())):
	a = int(input())
	s = len(str(a))
	res = 10 * (a % 10 - 1)
	print(res + s * (s + 1) // 2)


import math
t = int(input())
while t:
	x = input()
	length = len(x)
	digit = int(x[0])
	pre = 10 * (digit - 1)
	cur = length * (length + 1) // 2
	print(pre + cur)
	t = t - 1


import sys
try:
	import os
	f = open('input.txt', 'r')
	sys.stdin = f
except FileNotFoundError:
	None
from math import sqrt, ceil
input = lambda : sys.stdin.readline().strip()
n = int(input())
for _ in range(n):
	a = input()
	l = len(a)
	a = int(a[0])
	print(10 * (a - 1) + l * (l + 1) // 2)


for i in range(int(input())):
	shr_num = input()
	a = shr_num[0]
	shr_sum = (int(a) - 1) * 10
	for j in range(len(shr_num)):
		shr_sum += j + 1
	print(shr_sum)


n = int(input())
x = []
for i in range(n):
	x.append(int(input()))
for i in x:
	count = 0
	mod = i % 10
	multiple = (mod - 1) * 10
	while i != 0:
		i //= 10
		count += 1
	if count == 1 or count == 2:
		print(multiple + (2 * count - 1))
	elif count == 3:
		print(multiple + 6)
	else:
		print(multiple + 10)


for t in range(int(input())):
	ans = 0
	a = input()
	print((int(a[0]) - 1) * 10 + (1 + len(a)) * len(a) // 2)


for _ in range(int(input())):
	n = input()
	l = len(n)
	s = l * (l + 1) / 2
	s += (int(n[0]) - 1) * 10
	print(int(s))


n = int(input())
for i in range(n):
	a = int(input())
	o = a % 10
	c = (o - 1) * 10
	d = 1
	while a != 0:
		a = a // 10
		c += d
		d += 1
	print(c)


n = int(input())
sch = 0
for i in range(n):
	s = input()
	if len(s) == 1:
		sch = 1
	elif len(s) == 2:
		sch = 3
	elif len(s) == 3:
		sch = 6
	else:
		sch = 10
	print((int(s[0]) - 1) * 10 + sch, sep='')


t = int(input())
final = []
for counter in range(0, t):
	x = int(input())
	n = x
	y = 0
	while n > 0:
		y = y + 1
		n = n // 10
	ans = (x % 10 - 1) * 10 + y * (y - 1) / 2 + y
	final.append(ans)
for counter in range(0, t):
	print(int(final[counter]))


t = int(input())
for test in range(t):
	n = input()
	a = (int(n[0]) - 1) * 10
	if len(n) == 1:
		a += 1
	elif len(n) == 2:
		a += 3
	elif len(n) == 3:
		a += 6
	else:
		a += 10
	print(a)


for _ in range(int(input())):
	n = int(input())
	ans = 0
	fl = 0
	for i in range(1, 10):
		for j in range(1, 5):
			st = str(i) * j
			ans += j
			if st == str(n):
				fl = 1
				break
		if fl == 1:
			break
	print(ans)


import math
t = int(input())
k = 0
while k != t:
	A = int(input())
	if A < 10:
		A = 10 * (A % 10 - 1) + 1
	elif A >= 10 and A < 100:
		A = 10 * (A % 10 - 1) + 3
	elif A >= 100 and A < 1000:
		A = 10 * (A % 10 - 1) + 6
	elif A >= 1000 and A < 10000:
		A = 10 * (A % 10 - 1) + 10
	print(A)
	k = k + 1


from sys import stdin, stdout
import bisect
from bisect import bisect_left as bl
from bisect import bisect_right as br
import itertools
from collections import Counter
from math import sqrt
import collections
import math
import heapq
import re

def modinv(n, p):
	return pow(n, p - 2, p)

def cin():
	return map(int, sin().split())

def ain():
	return list(map(int, sin().split()))

def sin():
	return input()

def inin():
	return int(input())

def Divisors(n):
	l = []
	for i in range(1, int(math.sqrt(n) + 1)):
		if n % i == 0:
			if n // i == i:
				l.append(i)
			else:
				l.append(i)
				l.append(n // i)
	return l

def most_frequent(list):
	return max(set(list), key=list.count)

def GCD(x, y):
	while y:
		(x, y) = (y, x % y)
	return x

def ncr(n, r, p):
	t = fact[n] * (ifact[r] * ifact[n - r] % p) % p
	return t

def Convert(string):
	li = list(string.split(''))
	return li

def SieveOfEratosthenes(n):
	global prime
	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
	f = []
	for p in range(2, n):
		if prime[p]:
			f.append(p)
	return f
prime = []
q = []

def dfs(n, d, v, c):
	global q
	v[n] = 1
	x = d[n]
	q.append(n)
	j = c
	for i in x:
		if i not in v:
			f = dfs(i, d, v, c + 1)
			j = max(j, f)
	return j

def main():
	for _ in range(int(input())):
		n = inin()
		temp = len(str(n))
		k = int(str(n)[-1])
		ans = 10 * (k - 1)
		if temp == 1:
			ans += 1
		elif temp == 2:
			ans += 3
		elif temp == 3:
			ans += 6
		else:
			ans += 10
		print(ans)
py2 = round(0.5)
if py2:
	from future_builtins import ascii, filter, hex, map, oct, zip
	range = xrange
import os, sys
from io import IOBase, BytesIO
BUFSIZE = 8192

class FastIO(BytesIO):
	newlines = 0

	def __init__(self, file):
		self._file = file
		self._fd = file.fileno()
		self.writable = 'x' in file.mode or 'w' in file.mode
		self.write = super(FastIO, self).write if self.writable else None

	def _fill(self):
		s = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
		self.seek((self.tell(), self.seek(0, 2), super(FastIO, self).write(s))[0])
		return s

	def read(self):
		while self._fill():
			pass
		return super(FastIO, self).read()

	def readline(self):
		while self.newlines == 0:
			s = self._fill()
			self.newlines = s.count(b'\n') + (not s)
		self.newlines -= 1
		return super(FastIO, self).readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.getvalue())
			(self.truncate(0), self.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		if py2:
			self.write = self.buffer.write
			self.read = self.buffer.read
			self.readline = self.buffer.readline
		else:
			self.write = lambda s: self.buffer.write(s.encode('ascii'))
			self.read = lambda : self.buffer.read().decode('ascii')
			self.readline = lambda : self.buffer.readline().decode('ascii')
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
input = lambda : sys.stdin.readline().rstrip('\r\n')
main()


t = int(input())
for k in range(t):
	x = input()
	s = len(x)
	l = int(x[0])
	print(s * (s + 1) // 2 + 10 * (l - 1))


numOfCase = int(input())
cases = []
for i in range(numOfCase):
	cases.append(int(input()))
result = []
sum = 0
for i in range(5):
	sum += i
	result.append(sum)
final = []
i = 0
for case in cases:
	n = case % 10
	final.append((n - 1) * 10 + result[len(str(case))])
for j in final:
	print(j)


t = int(input())
while t > 0:
	x = input()
	n = len(x)
	print(10 * (int(x[0]) - 1) + n * (n + 1) // 2)
	t = t - 1


a = []
for i in range(1, 10):
	for j in range(1, 5):
		a.append(str(i) * j)
for i in range(int(input())):
	inp = input()
	s = 0
	for i in a:
		s += len(i)
		if i == inp:
			print(s)
			break


T = int(input())
for _ in range(T):
	a = int(input())
	start = a % 10
	digits = 0
	while a > 0:
		digits += 1
		a = a // 10
	print(int((start - 1) * 10 + digits * (digits + 1) / 2))


from math import *
from bisect import *
from collections import *
from random import *
from decimal import *
from itertools import *
import sys
input = sys.stdin.readline

def inp():
	return int(input())

def st():
	return input().rstrip('\n')

def lis():
	return list(map(int, input().split()))

def ma():
	return map(int, input().split())
t = inp()
while t:
	t -= 1
	n = inp()
	x = n % 10
	s = 10 * (x - 1)
	l = len(str(n))
	s += l * (l + 1) // 2
	print(s)


t = int(input())
tab = [1, 3, 6, 10]
for i in range(t):
	x = int(input())
	rangee = x % 10
	res = 10 * (rangee - 1) + tab[len(str(x)) - 1]
	print(res)


for _ in range(int(input())):
	n = int(input())
	if n % 10 == 1:
		l = len(str(n))
		s = 0
		for i in range(1, l + 1):
			s += i
		print(s)
	else:
		a1 = (1 + 2 + 3 + 4) * (n % 10 - 1)
		l = len(str(n))
		s = 0
		for i in range(1, l + 1):
			s += i
		print(a1 + s)


for _ in range(int(input())):
	x = int(input())
	count = 10 * (x % 10 - 1)
	for i in range(1, len(str(x)) + 1):
		count += i
	print(count)


ans = dict()
count = 0
for i in range(1, 10):
	for j in range(1, 5):
		digits = str(i) * j
		count += len(digits)
		ans[int(digits)] = count
for t in range(int(input())):
	print(ans[int(input())])


t = int(input(''))
for i in range(t):
	x = input('')
	xl = len(x)
	x = int(x[0])
	ans = (x - 1) * 10 + (xl + 1) * (xl / 2)
	ans = int(ans)
	print(ans)


arr = [str(i) * j for i in range(1, 10) for j in range(1, 5)]
for _ in range(int(input())):
	x = input()
	count = 0
	for el in arr:
		count += len(el)
		if el == x:
			break
	print(count)


t = int(input())
for i in range(t):
	string = input()
	length = len(string)
	var = int(string[0])
	k = var - 1
	tot = int(k * 10 + length * (length + 1) / 2)
	print(tot)


s = []
for i in range(1, 10):
	for j in range(1, 5):
		s.append(str(i) * j)
t = int(input())
for _ in range(t):
	c = 0
	x = input()
	for i in range(len(s)):
		if s[i] == x:
			c += len(list(s[i]))
			break
		else:
			c += len(list(s[i]))
	print(c)


t = int(input())
for i in range(t):
	p = input()
	s = int(p) % 10
	m = p.count(str(s))
	if m == 1:
		print(1 + (s - 1) * 10)
	elif m == 2:
		print(3 + (s - 1) * 10)
	elif m == 3:
		print(6 + (s - 1) * 10)
	elif m == 4:
		print(s * 10)


import os
import sys, math
from io import BytesIO, IOBase

def main():
	t = int(input())
	for case in range(t):
		x = int(input())
		dig = int(str(x)[0])
		ans = 0
		for i in range(1, dig + 1):
			if i != dig:
				ans += 10
			else:
				ln = len(str(x))
				if ln == 1:
					ans += 1
				elif ln == 2:
					ans += 3
				elif ln == 3:
					ans += 6
				else:
					ans += 10
				break
		print(ans)
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
input = lambda : sys.stdin.readline().rstrip('\r\n')
main()


from sys import stdin, stdout
from math import gcd, sqrt, factorial, pi, inf
from collections import deque, defaultdict
input = stdin.readline
R = lambda : map(int, input().split())
I = lambda : int(input())
S = lambda : input().rstrip('\n')
L = lambda : list(R())
P = lambda x: stdout.write(str(x) + '\n')
lcm = lambda x, y: x * y // gcd(x, y)
hg = lambda x, y: (y + x - 1) // x * x
pw = lambda x: 1 if x == 1 else 1 + pw(x // 2)
chk = lambda x: chk(x // 2) if not x % 2 else True if x == 1 else False
sm = lambda x: (x ** 2 + x) // 2
N = 10 ** 6 + 6
for _ in range(I()):
	s = S()
	print((int(s[-1]) - 1) * 10 + (len(s) ** 2 + len(s)) // 2)


for _ in range(int(input())):
	num = int(input())
	new_num = (num % 10 - 1) * 10
	l = len(str(num))
	arr = [1, 3, 6, 10]
	new_num += arr[l - 1]
	print(new_num)


t = int(input())
l = [0, 1]
for i in range(2, 1000):
	l.append(i * i)
while t:
	t -= 1
	a = int(input())
	k = len(str(a))
	k -= 1
	s = str(a)
	ans = (int(s[0]) - 1) * 10
	if len(s) == 1:
		ans += 1
	elif len(s) == 2:
		ans += 3
	elif len(s) == 3:
		ans += 6
	else:
		ans += 10
	print(ans)


def solution():
	x = input().strip()
	(digit, num) = (int(x[0]), len(x))
	return 10 * (digit - 1) + num * (num + 1) // 2

def main():
	T = int(input().strip())
	for t in range(1, T + 1):
		print(solution())
main()


for _ in range(int(input())):
	n = int(input())
	a = [1, 2, 3, 4]
	d = 0
	x = (n % 10 - 1) * 10
	while n > 0:
		n //= 10
		d += 1
	print(x + sum(a[0:d]))


list1 = ['1', '11', '111', '1111', '2', '22', '222', '2222', '3', '33', '333', '3333', '4', '44', '444', '4444', '5', '55', '555', '5555', '6', '66', '666', '6666', '7', '77', '777', '7777', '8', '88', '888', '8888', '9', '99', '999', '9999']
list2 = [1, 2, 3, 4, 1, 2, 3, 4, 1, 2, 3, 4, 1, 2, 3, 4, 1, 2, 3, 4, 1, 2, 3, 4, 1, 2, 3, 4, 1, 2, 3, 4, 1, 2, 3, 4]
m = int(input())
z = []
for i in range(m):
	l = input()
	k = list1.index(l)
	z.append(sum(list2[0:k + 1]))
for i in z:
	print(i)


for _ in range(int(input())):
	a = int(input())
	c = 0
	c += 10 * (a % 10 - 1) + 1
	if a > 10:
		c += 2
	if a > 100:
		c += 3
	if a > 1000:
		c += 4
	print(c)


num = int(input())
inps = []
for i in range(0, num):
	inps.append(int(input()))
for i in range(0, num):
	n = inps[i]
	number = 0
	cur = 0
	count = 0
	b = 1
	while b == 1:
		number += 1
		now = 0
		cur = 0
		while b == 1 and cur < 4:
			now += number * 10 ** cur
			count += cur + 1
			if now == n:
				b = 0
			cur += 1
	print(count)


t = int(input())
for _ in range(t):
	n = int(input())
	x = n % 10
	l = len(str(n))
	print((x - 1) * 10 + (l + 1) * l // 2)


for _ in range(int(input())):
	n = int(input())
	a = n % 10
	ans = (a - 1) * 10
	b = len(str(n))
	ans += b * (b + 1) // 2
	print(ans)


t = int(input())
for i in range(0, t):
	num = input()
	sum1 = (int(num[0]) - 1) * 10
	if len(num) == 1:
		sum1 += 1
	elif len(num) == 2:
		sum1 += 3
	elif len(num) == 3:
		sum1 += 6
	elif len(num) == 4:
		sum1 += 10
	print(sum1)


from sys import stdin, stdout
import heapq
import cProfile
from collections import Counter, defaultdict, deque
from functools import reduce
import math
import threading
import sys
import time

def get_int():
	return int(stdin.readline().strip())

def get_tuple():
	return map(int, stdin.readline().split())

def get_list():
	return list(map(int, stdin.readline().split()))

def solve():
	n = get_int()
	d = n % 10
	ls = [d, d * 10 + d, d * 100 + d * 10 + d, d * 1000 + d * 100 + d * 10 + d]
	temp = [1, 3, 6, 10]
	ans = (d - 1) * 10
	ans += temp[ls.index(n)]
	print(ans)

def main():
	solve()
TestCases = True
if TestCases:
	for i in range(get_int()):
		main()
else:
	main()


for _ in range(int(input())):
	x = int(input())
	count = 0
	for i in range(1, 10):
		sum = 0
		flag = 0
		for j in range(1, 5):
			sum = sum * 10 + i
			count = count + j
			if sum == x:
				print(count)
				flag = -1
		if flag == -1:
			break


a = int(input())
b = []
f = []
g = []
for n in range(a):
	e = input()
	f.append(e)
for i in range(1, 10):
	d = [str(i) * n for n in range(1, 5)]
	b.append(d)
for m in range(len(b)):
	for i in range(len(b[m])):
		g.append(b[m][i])
for o in f:
	if g.index(o) % 4 == 0:
		print(g.index(o) // 4 * 10 + 1)
	elif g.index(o) % 4 == 1:
		print(g.index(o) // 4 * 10 + 3)
	elif g.index(o) % 4 == 2:
		print(g.index(o) // 4 * 10 + 6)
	elif g.index(o) % 4 == 3:
		print(g.index(o) // 4 * 10 + 10)


arr = []
for i in range(1, 10):
	for j in range(1, 5):
		arr.append(str(i) * j)
t = int(input())
for _ in range(t):
	n = str(input())
	x = arr.index(n)
	ans = 0
	for j in range(x + 1):
		ans += len(arr[j])
	print(ans)


from sys import stdin, stdout
from math import *
from collections import *
mod = 1000000007

def gcd(a, b):
	while b:
		(a, b) = (b, a % b)
	return a

def lcm(a, b):
	return a * b // gcd(a, b)

def set_bits(X):
	c = 0
	while X:
		X &= X - 1
		c += 1
	return c

def compute_MOD(N, M):
	return (N % M + M) % M

def get_array():
	return list(map(int, stdin.readline().split()))

def get_ints():
	return map(int, stdin.readline().split())

def get_int():
	return int(stdin.readline())

def get_input():
	return stdin.readline().strip()

def main():
	tc = get_int()
	while tc:
		N = input()
		x = ord(N[0]) - ord('0') - 1
		ans = (1 + 2 + 3 + 4) * x
		for i in range(1, len(N) + 1):
			ans += i
		stdout.write(str(ans) + '\n')
		tc -= 1
main()


import sys
try:
	(sys.stdin, sys.stdout) = (open('in.txt', 'r'), open('out.txt', 'w'))
except:
	pass
ii1 = lambda : int(sys.stdin.readline().strip())
is1 = lambda : sys.stdin.readline().strip()
iia = lambda : list(map(int, sys.stdin.readline().strip().split()))
isa = lambda : sys.stdin.readline().strip().split()
mod = int(1000000000.0 + 7)
from collections import *
from math import *
apartment = [1, 11, 111, 1111, 2, 22, 222, 2222, 3, 33, 333, 3333, 4, 44, 444, 4444, 5, 55, 555, 5555, 6, 66, 666, 6666, 7, 77, 777, 7777, 8, 88, 888, 8888, 9, 99, 999, 9999]
for _ in range(ii1()):
	n = ii1()
	ans = 0
	for i in range(40):
		if apartment[i] == n:
			ans += len(str(apartment[i]))
			break
		ans += len(str(apartment[i]))
	print(ans)


t = int(input())
for i in range(t):
	n = int(input())
	leng = len(str(n))
	rem = n % 10
	counte = 0
	if rem == 1:
		for j in range(1, leng + 1):
			counte += j
		print(counte)
		continue
	counte = (rem - 1) * 10
	if leng == 1:
		counte += 1
	if leng == 2:
		counte += 3
	if leng == 3:
		counte += 6
	if leng == 4:
		counte += 10
	print(counte)


t = int(input())
for _ in range(t):
	s = input()
	x = int(s[0])
	y = len(s)
	print((x - 1) * 10 + [0, 1, 3, 6, 10][y])


t = int(input())
while t:
	t -= 1
	num = int(input())
	d = num % 10
	count = 0
	while num:
		count += 1
		num //= 10
	res = 0
	if count == 1:
		res += 1
	elif count == 2:
		res += 3
	elif count == 3:
		res += 6
	else:
		res += 10
	res += (d - 1) * 10
	print(res)


from sys import stdin
tc = int(stdin.readline().strip())

def rspos(num):
	if num == 1:
		return 1
	elif num == 2:
		return 2
	elif num == 3:
		return 3
	elif num == 4:
		return 4
for _ in range(tc):
	nn = int(stdin.readline().strip())
	ans = 0
	required = [1, 2, 3, 4]
	lns = len(str(nn))
	firstchar = nn % 10
	if firstchar == 1:
		getpos = rspos(lns)
		if getpos == 1:
			print(1)
		else:
			print(sum(required[:lns]))
	else:
		ans = sum(required) * int(firstchar - 1)
		getpos = rspos(lns)
		ans += sum(required[:getpos])
		print(ans)


def func():
	a = int(input())
	arr = [1, 2, 3, 4]
	summa = 0
	summa += 10 * (a % 10 - 1) + sum(arr[0:len(str(a))])
	print(summa)
num = int(input())
while num:
	num -= 1
	func()


n = int(input())
counter = 0
flag = 0
for i in range(n):
	counter = 0
	flag = 0
	num = int(input())
	for j in range(1, 10):
		for k in range(1, 5):
			stroka = str(j) * k
			if str(j) * k != str(num):
				counter += k
			else:
				flag = 1
				counter += k
				break
		if flag == 1:
			break
	print(counter)


t = int(input())
l = []
a = 0
s = ''
d = 0
r = []
dummy = [1, 3, 6, 10]
for i in range(t):
	a = int(input())
	l.append(a)
for i in l:
	s = str(i)
	a = int(s[0])
	d = (a - 1) * 10 + dummy[len(s) - 1]
	r.append(d)
for i in r:
	print(i)


for __ in range(int(input())):
	n = input()
	l = ord(n[0]) - ord('0') - 1
	k = len(n)
	print(l * 10 + k * (k + 1) // 2)


import math
import sys
input = lambda : sys.stdin.readline().rstrip()
for _ in range(int(input())):
	s = input()
	ans = 0
	cur = '1'
	while cur != s:
		ans += len(cur)
		cur += cur[0]
		if len(cur) == 5:
			cur = str(int(cur[0]) + 1)
	ans += len(cur)
	print(ans)


def press_count(flat):
	count = 0
	for i in range(1, 10):
		cur_flat = i
		count += 1
		if cur_flat == flat:
			return count
		for j in range(3):
			cur_flat = cur_flat * 10 + i
			count += j + 2
			if cur_flat == flat:
				return count
n_req = int(input())
for i in range(n_req):
	print(press_count(int(input())))


rn = lambda : int(input())
rl = lambda : list(map(int, input().split()))
rns = lambda : map(int, input().split())
rs = lambda : input()
yn = lambda x: print('Yes') if x else print('No')
YN = lambda x: print('YES') if x else print('NO')
for _ in range(rn()):
	x = rs()
	n = int(x[0])
	ans = 10 * (n - 1)
	for i in range(len(x) + 1):
		ans += i
	print(ans)


for t in range(int(input())):
	x = int(input())
	y = str(x)
	n = len(y)
	p = pow(10, n - 1)
	a = int(x / p)
	a = a * 10
	sum1 = n * (n + 1) / 2
	a = a - (10 - sum1)
	print(int(a))


def boring():
	test_cases = int(input())
	args = [int(input()) for i in range(test_cases)]
	for num in args:
		count = n = 0
		while num:
			n = num % 10
			num //= 10
			count += 1
		res = (n - 1) * 10 + count * (count + 1) // 2
		print(res)
boring()


t = int(input())
for i in range(t):
	summa = 0
	a = int(input())
	n = a % 10
	i_min = 1
	while i_min < n:
		summa += 10
		i_min += 1
	if i_min == n:
		if i_min <= a:
			summa += 1
		if i_min * 10 + i_min <= a:
			summa += 2
		if i_min * 100 + i_min * 10 + i_min <= a:
			summa += 3
		if i_min * 1000 + i_min * 100 + i_min * 10 + i_min <= a:
			summa += 4
	print(summa)


for i in range(int(input())):
	s = str(input())
	n = int(s)
	print(int((n % 10 - 1) * 10 + len(s) * (len(s) + 1) / 2))


t = int(input())
for i in range(t):
	x = input()
	n = int(x[0])
	count = (n - 1) * 10 + len(x) * (len(x) + 1) // 2
	print(count)


num_test_cases = int(input())
for i in range(num_test_cases):
	final_apartment = int(input())
	digit = final_apartment % 10
	initial_blocks = (digit - 1) * 10
	length = len(str(final_apartment))
	total = initial_blocks
	for j in range(1, length + 1):
		total += j
	print(total)


t = int(input())
for i in range(t):
	ans_num = int(input().strip())
	ans_val = ans_num % 10
	ans_digi = 0
	while ans_num != 0:
		ans_num = int(ans_num / 10)
		ans_digi = ans_digi + 1
	print(10 * (ans_val - 1) + int((ans_digi + 1) * ans_digi / 2))


def fac(n):
	if n == 1:
		return 1
	return n + fac(n - 1)
t = int(input())
for i in range(t):
	n = input()
	print(10 * (int(n[0]) - 1) + fac(len(n)))


import math
import sys, bisect
from heapq import *
from itertools import *
from collections import *
sys.setrecursionlimit(10 ** 6)
I = lambda : int(sys.stdin.readline())
neo = lambda : map(int, sys.stdin.readline().split())
Neo = lambda : list(map(int, sys.stdin.readline().split()))
for _ in range(I()):
	s = input()
	n = int(s[0])
	Ans = 0
	for i in range(1, n):
		Ans += 10
	k = len(s)
	Ans += k * (k + 1) // 2
	print(Ans)


n = int(input())
ans = 0
for i in range(n):
	a = int(input())
	s = str(a)
	nn = int(s[0])
	le = len(s)
	for j in range(1, nn):
		ans += 10
	if le == 4:
		ans += 10
	if le == 3:
		ans += 6
	if le == 2:
		ans += 3
	if le == 1:
		ans += 1
	print(ans)
	ans = 0


t = int(input())
for i in range(t):
	x = input()
	x1 = x[0]
	x1 = int(x1)
	arr = [1, 3, 6, 10]
	k = (x1 - 1) * 10 + arr[len(x) - 1]
	print(k)


listV = []
for i in range(int(input())):
	listV.append(int(input()))

	def func(num):
		if num == 1:
			return 1
		lenght = len(str(num))
		if lenght == 1:
			num = 11111 * (num - 1)
		return lenght + func(num // 10)
for i in listV:
	print(func(i))


import math
l = []
for i in range(1, 10):
	for j in range(1, 5):
		l.append(j * str(i))
for _ in range(int(input())):
	n = int(input())
	n = str(n)
	d = l.index(n)
	c = 1
	ans = 0
	for i in range(d + 1):
		ans += len(l[i])
	print(ans)


t = int(input())
answers = []
for _ in range(t):
	x = int(input())
	a = 0
	for i in range(9):
		if str(i + 1) not in str(x) and str(i + 1) < str(x)[0]:
			a += 10
		if str(i + 1) in str(x):
			for j in range(len(str(x))):
				a += j + 1
	answers.append(a)
for k in range(t):
	print(answers[k])


t = int(input())
for i in range(t):
	n = int(input())
	counter = 0
	counter += (n % 10 - 1) * 10
	s = str(n)
	j = s[0]
	if s.count(j) == 1:
		counter += 1
	elif s.count(j) == 2:
		counter += 2 + 1
	elif s.count(j) == 3:
		counter += 3 + 2 + 1
	elif s.count(j) == 4:
		counter += 4 + 3 + 2 + 1
	print(counter)


n = int(input())
a = []
for i in range(n):
	a.append(input())
b = []
for i in a:
	t = int(i[0])
	n = len(i)
	b.append((t - 1) * 10 + n * (n + 1) // 2)
print(*b, sep='\n')


for _ in range(int(input())):
	n = int(input())
	ndig = 0
	num = n
	rem = 0
	while num != 0:
		ndig += 1
		rem = num % 10
		num //= 10
	ans = ndig * (ndig + 1) // 2
	ans += 10 * (rem - 1)
	print(ans)


def solution():
	num = int(input())
	out = []
	for i in range(num):
		test = input()
		if len(test) == 4:
			test += test[0] * 2
		numb = int(test)
		result = proces(numb)
		out.append(result)
	for i in out:
		print(i)

def proces(n):
	main = [str(i) for i in range(1, 10)]
	for i in range(2, 4):
		temp = [i * j for j in main]
		main.extend(temp)
	main = list(sorted(main))
	idx = 0
	res = [1, 2, 3, 4]
	for i in range(len(main)):
		if main[i] == str(n):
			idx = i + 1
	major = int(idx // 4 * 10)
	minor = int(idx % 4)
	mina = sum(res[:minor])
	return major + mina
solution()


import math
n = int(input())
arr = []
for i in range(n):
	arr.append(int(input()))

def check(n):
	if n == 1:
		return 1
	order = math.ceil(math.log10(n))
	first = n // 10 ** (order - 1)
	res = 10 * (first - 1)
	for i in range(1, order + 1):
		if n >= (10 ** i - 1) // 9 * first:
			res += i
		else:
			break
	return res
for i in arr:
	print(check(i))


from math import log10
base = [1, 11, 111, 1111]
bore = []
for i in range(1, 10):
	for j in range(4):
		if base[j] * i <= 10000:
			bore.append(i * base[j])
T = int(input())
for _ in range(T):
	n = int(input())
	sum = 0
	index = bore.index(n)
	for k in range(index + 1):
		sum += int(log10(bore[k])) + 1
	print(sum)


for _ in ' ' * int(input()):
	n = int(input())
	ln = len(list(str(n)))
	s = 10 * (n % 10 - 1) + ln * (ln + 1) / 2
	print(int(s))


import sys
input = sys.stdin.readline

def inp():
	return int(input())

def inlt():
	return list(map(int, input().split()))

def insr():
	s = input()
	return list(s[:len(s) - 1])

def invr():
	return map(int, input().split())
sum = 10

def solve():
	t = inp()
	while t > 0:
		num = input()
		siz = len(num)
		add = int(siz * (siz - 1) / 2)
		n_it = int(num) % 10 - 1
		total = n_it * sum + add
		print(total)
		t -= 1
solve()


from bisect import *
from collections import *
from math import gcd, ceil, sqrt, floor
from heapq import *
from typing import List
from itertools import *
from operator import add, mul, sub, xor, truediv, floordiv
from functools import *
import os
import sys
from io import BytesIO, IOBase
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
input = lambda : sys.stdin.readline().rstrip('\r\n')

def RL():
	return map(int, sys.stdin.readline().rstrip().split())

def RLL():
	return list(map(int, sys.stdin.readline().rstrip().split()))

def N():
	return int(input())

@lru_cache(None)
def fact(x):
	if x < 2:
		return 1
	return fact(x - 1) * x

@lru_cache(None)
def per(i, j):
	return fact(i) // fact(i - j)

@lru_cache(None)
def com(i, j):
	return per(i, j) // fact(j)

def linc(f, t, l, r):
	while l < r:
		mid = (l + r) // 2
		if t > f(mid):
			l = mid + 1
		else:
			r = mid
	return l

def rinc(f, t, l, r):
	while l < r:
		mid = (l + r + 1) // 2
		if t < f(mid):
			r = mid - 1
		else:
			l = mid
	return l

def ldec(f, t, l, r):
	while l < r:
		mid = (l + r) // 2
		if t < f(mid):
			l = mid + 1
		else:
			r = mid
	return l

def rdec(f, t, l, r):
	while l < r:
		mid = (l + r + 1) // 2
		if t > f(mid):
			r = mid - 1
		else:
			l = mid
	return l

def isprime(n):
	for i in range(2, int(n ** 0.5) + 1):
		if n % i == 0:
			return False
	return True

def binfun(x):
	c = 0
	for w in arr:
		c += ceil(w / x)
	return c

def lowbit(n):
	return n & -n

class BIT:

	def __init__(self, arr):
		self.arr = arr
		self.n = len(arr) - 1

	def update(self, x, v):
		while x <= self.n:
			self.arr[x] += v
			x += x & -x

	def query(self, x):
		ans = 0
		while x:
			ans += self.arr[x]
			x &= x - 1
		return ans

class smt:

	def __init__(self, l, r, arr):
		self.l = l
		self.r = r
		self.value = (1 << 31) - 1 if l < r else arr[l]
		mid = (l + r) // 2
		if l < r:
			self.left = smt(l, mid, arr)
			self.right = smt(mid + 1, r, arr)
			self.value &= self.left.value & self.right.value

	def setvalue(self, x, val):
		if self.l == self.r:
			self.value = val
			return
		mid = (self.l + self.r) // 2
		if x <= mid:
			self.left.setvalue(x, val)
		else:
			self.right.setvalue(x, val)
		self.value = self.left.value & self.right.value

	def ask(self, l, r):
		if l <= self.l and r >= self.r:
			return self.value
		val = (1 << 31) - 1
		mid = (self.l + self.r) // 2
		if l <= mid:
			val &= self.left.ask(l, r)
		if r > mid:
			val &= self.right.ask(l, r)
		return val

class UFS:

	def __init__(self, n):
		self.parent = [i for i in range(n)]
		self.ranks = [0] * n

	def find(self, x):
		if x != self.parent[x]:
			self.parent[x] = self.find(self.parent[x])
		return self.parent[x]

	def union(self, u, v):
		(pu, pv) = (self.find(u), self.find(v))
		if pu == pv:
			return False
		if self.ranks[pu] >= self.ranks[pv]:
			self.parent[pv] = pu
			if self.ranks[pv] == self.ranks[pu]:
				self.ranks[pu] += 1
		else:
			self.parent[pu] = pv

def Prime(n):
	c = 0
	prime = []
	flag = [0] * (n + 1)
	for i in range(2, n + 1):
		if not flag[i]:
			prime.append(i)
			c += 1
		for j in range(c):
			if i * prime[j] > n:
				break
			flag[i * prime[j]] = prime[j]
			if i % prime[j] == 0:
				break
	return prime

def dij(s, graph):
	d = {}
	d[s] = 0
	heap = [(0, s)]
	seen = set()
	while heap:
		(dis, u) = heappop(heap)
		if u in seen:
			continue
		for v in graph[u]:
			if v not in d or d[v] > d[u] + graph[u][v]:
				d[v] = d[u] + graph[u][v]
				heappush(heap, (d[v], v))
	return d

def md(a, b, mod):
	return a * pow(b, mod - 2, mod) % mod
t = N()
for i in range(t):
	x = N()
	d = x % 10
	n = len(str(x))
	ans = (d - 1) * 10 + n * (n + 1) // 2
	print(ans)


tc = int(input())
for tcc in range(1, tc + 1):
	s = input()
	l = int(s)
	le = len(s)
	dig = int(s[0])
	tot = (dig - 1) * 10
	tot = tot + le * (le + 1) // 2
	print(tot)


for j in range(int(input())):
	a = input()
	v = a[0]
	x = len(a)
	if x == 4:
		print(int(v) * 10)
	elif x == 3:
		print(int(v) * 10 - 4)
	elif x == 2:
		print(int(v) * 10 - 7)
	else:
		print(int(v) * 10 - 9)


def f(n):
	c = len(str(n))
	if c == 1:
		return 10 * (n % 10 - 1) + 1
	elif c == 2:
		return 10 * (n % 10 - 1) + 3
	elif c == 3:
		return 10 * (n % 10 - 1) + 6
	else:
		return 10 * (n % 10 - 1) + 10
for _ in range(int(input())):
	print(f(int(input())))


for i in range(int(input())):
	x = list(map(int, input()))
	z = len(x) * (len(x) + 1) // 2
	print(10 * (x[0] - 1) + z)


for _ in range(int(input())):
	a = int(input())
	ans = 0
	for i in range(1, a % 10):
		ans += 10
	i = 0
	while a > 0:
		a //= 10
		i += 1
	ans += i * (i + 1) // 2
	print(ans)


t = int(input())
for _ in range(t):
	s = input()
	x = {1: 1, 11: 3, 111: 6, 1111: 10}
	ans = 0
	f = int(s[0])
	ans += (f - 1) * 10 + x[int(s) // f]
	print(ans)


n = int(input())

def number_calc():
	ls = []
	bor = []
	for i in range(1, 10001):
		digits = [int(x) for x in str(i)]
		if len(digits) == 1:
			bor.append(i)
		elif digits.count(digits[0]) == len(digits):
			bor.append(i)
	return bor
bor2 = number_calc()
bor2str = []
for items in bor2:
	bor2str.append(str(items))
sorbor2str = sorted(bor2str)
for t in range(0, n):
	val = int(input())
	lencount = 0
	for items in sorbor2str:
		if int(items) != val:
			lencount += len(items)
		else:
			lencount += len(items)
			break
	print(lencount)


from collections import Counter
for _ in range(int(input())):
	s = 0
	n = input()
	j = int(str(n)[0]) - 1
	s += 10 * j
	if len(n) == 1:
		s += 1
	elif len(n) == 2:
		s += 3
	elif len(n) == 3:
		s += 6
	elif len(n) == 4:
		s += 10
	print(s)


l = [s * i for s in '123456789' for i in range(1, 5)]
x = [1]
for i in l[1:]:
	x.append(x[-1] + len(i))
n = int(input())
for _ in range(n):
	i = input()
	print(x[l.index(i)])


a = int(input())
for i in range(0, a):
	b = list(map(str, input()))
	c = (int(b[0]) - 1) * 10
	d = len(b)
	e = 0
	for i in range(1, d + 1):
		e += int(i)
	print(c + e)


lis = [1, 11, 111, 1111, 2, 22, 222, 2222, 3, 33, 333, 3333, 4, 44, 444, 4444, 5, 55, 555, 5555, 6, 66, 666, 6666, 7, 77, 777, 7777, 8, 88, 888, 8888, 9, 99, 999, 9999]
import math
for _ in range(int(input())):
	x = int(input())
	ans = 1
	for i in lis:
		if int(str(x)[0:1]) > int(str(i)[0:1]):
			ans += math.ceil(math.log(i, 10))
		if int(str(x)[0:1]) == int(str(i)[0:1]) and x >= i:
			ans += math.ceil(math.log(i, 10))
	print(ans)


import io
import os
import math
input = io.BytesIO(os.read(0, os.fstat(0).st_size)).readline
for _ in range(int(input())):
	x = int(input())
	k = int(math.log10(x))
	if k == 0:
		k = 1
	elif k == 1:
		k = 3
	elif k == 2:
		k = 6
	elif k == 3:
		k = 10
	print((x % 10 - 1) * 10 + k)


n = int(input())
while n:
	n -= 1
	cur = input()
	tmp = 10 * (int(cur[0]) - 1)
	if len(cur) == 1:
		tmp += 1
	elif len(cur) == 2:
		tmp += 3
	elif len(cur) == 3:
		tmp += 6
	else:
		tmp += 10
	print(tmp)


import sys, os, io

def rs():
	return sys.stdin.readline().rstrip()

def ri():
	return int(sys.stdin.readline())

def ria():
	return list(map(int, sys.stdin.readline().split()))

def ws(s):
	sys.stdout.write(s + '\n')

def wi(n):
	sys.stdout.write(str(n) + '\n')

def wia(a):
	sys.stdout.write(' '.join([str(x) for x in a]) + '\n')
import math, datetime, functools, itertools, operator, bisect, fractions, statistics
from collections import deque, defaultdict, OrderedDict, Counter
from fractions import Fraction
from decimal import Decimal
from sys import stdout

def main():
	starttime = datetime.datetime.now()
	if os.path.exists('input.txt'):
		sys.stdin = open('input.txt', 'r')
		sys.stdout = open('output.txt', 'w')
	for _ in range(ri()):
		n = ri()
		a = [1, 11, 111, 1111]
		z = [1, 11, 111, 1111]
		for i in range(2, 10):
			for j in range(4):
				z.append(i * a[j])
		c = 0
		ans = 0
		for i in z:
			c += 1
			if c == 5:
				c = 1
			ans += c
			if i == n:
				print(ans)
				break
	endtime = datetime.datetime.now()
	time = (endtime - starttime).total_seconds() * 1000
	if os.path.exists('input.txt'):
		print('Time:', time, 'ms')

class FastReader(io.IOBase):
	newlines = 0

	def __init__(self, fd, chunk_size=1024 * 8):
		self._fd = fd
		self._chunk_size = chunk_size
		self.buffer = io.BytesIO()

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, self._chunk_size))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self, size=-1):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, self._chunk_size if size == -1 else size))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

class FastWriter(io.IOBase):

	def __init__(self, fd):
		self._fd = fd
		self.buffer = io.BytesIO()
		self.write = self.buffer.write

	def flush(self):
		os.write(self._fd, self.buffer.getvalue())
		(self.buffer.truncate(0), self.buffer.seek(0))

class FastStdin(io.IOBase):

	def __init__(self, fd=0):
		self.buffer = FastReader(fd)
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')

class FastStdout(io.IOBase):

	def __init__(self, fd=1):
		self.buffer = FastWriter(fd)
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.flush = self.buffer.flush
sys.stdin = FastStdin()
sys.stdout = FastStdout()
main()


t = int(input())
res = [0 for i in range(t)]
i = 0
while i < t:
	x = int(input())
	num = str(x)
	res[i] = 10 * (int(num[0]) - 1) + (len(num) + 1) * len(num) // 2
	i += 1
i = 0
while i < t:
	print(res[i])
	i += 1


t = int(input())
for _ in range(t):
	sting = input()
	how = len(sting)
	n = int(sting)
	digit = n % 10 - 1
	tens = 10 * digit
	if how == 1:
		print(tens + 1)
	if how == 2:
		print(tens + 3)
	if how == 3:
		print(tens + 6)
	if how == 4:
		print(tens + 10)


t = int(input())
ans = []
for i in range(t):
	numb = int(input())
	s = 0
	n = 1
	x = 1
	y = 0
	while n != numb % 10 + 1:
		if n < numb % 10:
			s += 10
		else:
			while x <= numb:
				x *= 10
				y += 1
				s += y
		n += 1
	ans.append(s)
for i in ans:
	print(i)


for _ in range(int(input())):
	x = input()
	dig = ord(x[0]) - ord('0') - 1
	l = len(x)
	print(dig * 10 + l * (l + 1) // 2)


boringNumbers = [1, 11, 111, 1111, 2, 22, 222, 2222, 3, 33, 333, 3333, 4, 44, 444, 4444, 5, 55, 555, 5555, 6, 66, 666, 6666, 7, 77, 777, 7777, 8, 88, 888, 8888, 9, 99, 999, 9999]
dic = {}
for i in range(len(boringNumbers)):
	dic[boringNumbers[i]] = i
t = int(input())
tests = []
out = []
for i in range(t):
	tests.append(int(input()))
for test in tests:
	if test in dic:
		idx = dic[test] + 1
		out.append(idx)
for i in range(len(out)):
	curr = out[i]
	for j in range(1, curr):
		out[i] += j % 4
for i in out:
	print(i)


for _ in range(int(input())):
	n = input()
	integer = int(n[0])
	res = integer - 1
	res = res * 10
	print(res + len(n) * (len(n) + 1) // 2)


def boring(x):
	x1 = str(x)
	a = int(x1[0])
	n = len(x1)
	hunds = 10 * (a - 1)
	tens = n * (n + 1) // 2
	sol = hunds + tens
	return sol
t = int(input())
for i in range(t):
	x = int(input())
	print(boring(x))


def calc(n):
	ans = 0
	limit = n % 10 - 1
	return limit * 10 + len(str(n)) * (len(str(n)) + 1) // 2
t = int(input())
for i in range(t):
	n = int(input())
	print(calc(n))


try:
	t = int(input())
	for _ in range(t):
		x = input()
		a = int(x[0])
		b = len(x)
		if b == 1:
			b = 1
		elif b == 2:
			b = 3
		elif b == 3:
			b = 6
		elif b == 4:
			b = 10
		print((a - 1) * 10 + b)
except:
	pass


lenToPresses = {1: 1, 2: 3, 3: 6, 4: 10}
T = int(input())
for t in range(T):
	x = input()
	print(10 * (int(x[0]) - 1) + lenToPresses[len(x)])


a = int(input())
for _ in range(a):
	n = int(input())
	ans = (n % 10 - 1) * 10
	k = len(str(n))
	if k == 1:
		ans += 1
	elif k == 2:
		ans += 3
	elif k == 3:
		ans += 6
	else:
		ans += 10
	print(ans)


import sys
input = lambda : sys.stdin.readline().rstrip()
from collections import deque
from queue import LifoQueue

def binary_search(a, n):
	L = 0
	R = len(a) - 1
	while L <= R:
		mid = L + (R - L) // 2
		if a[mid] == n:
			return mid
		elif a[mid] < n:
			L = mid + 1
		else:
			R = mid - 1
	return -1
for _ in range(int(input())):
	s = input()
	n = len(s)
	pp = int(s[0])
	ans = 0
	ans += 10 * (pp - 1)
	for i in range(n):
		ans += i + 1
	print(ans)


testcases = int(input())
for i in range(testcases):
	n = input()
	length = len(n)
	k = int(n[0])
	sum = (k - 1) * 10 + length * (length + 1) // 2
	print(sum)


def solve():
	n = input()
	if n == '1':
		print(1)
		return
	print((int(n[0]) - 1) * 10 + int(len(n) * (len(n) + 1) / 2))
for _ in range(int(input())):
	solve()


import sys

def input():
	return sys.stdin.readline().strip()

def mod():
	return 10 ** 9 + 7
a = [1, 11, 111, 1111, 2, 22, 222, 2222, 3, 33, 333, 3333, 4, 44, 444, 4444, 5, 55, 555, 5555, 6, 66, 666, 6666, 7, 77, 777, 7777, 8, 88, 888, 8888, 9, 99, 999, 9999]
b = [1, 3, 6, 10]

def countDigit(n):
	count = 0
	while n != 0:
		n //= 10
		count += 1
	return count
t = int(input())
while t:
	n = int(input())
	k = n % 10
	m = countDigit(n)
	print((k - 1) * 10 + b[m - 1])
	t -= 1


for j in range(int(input())):
	x = int(input())
	length = len(str(x))
	dig = int(str(x)[0])
	ans = (dig - 1) * (2 * 5)
	ans += length * (length + 1) // 2
	print(ans)


import sys, os
from io import BytesIO, IOBase
import collections, itertools, bisect, heapq, math, string
from decimal import *
BUFSIZE = 8192
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
input = lambda : sys.stdin.readline().rstrip('\r\n')

def main():
	t = int(input())
	for i in range(t):
		n = int(input())
		res = []
		for i in range(1, 10):
			for j in range(1, 5):
				res.append(int(str(i) * j))
		ans = 0
		for x in res:
			if n == x:
				ans += len(str(x))
				break
			ans += len(str(x))
		print(ans)
main()


t = int(input())

def nod(n):
	count = 0
	while n > 0:
		count += 1
		n //= 10
	return count
for _ in range(t):
	n = int(input())
	dig = nod(n)
	no = n % 10
	ans = (no - 1) * 10
	ans += dig * (dig + 1) // 2
	print(ans)


n = int(input())
for i in range(n):
	a = input()
	b = len(a) + 1
	w = 0
	for i in range(b):
		w = w + i
	print((int(a[0]) - 1) * 10 + w)


testCases = int(input())
boringApts = list()
for i in range(1, 10):
	ele = str(i)
	string = ''
	for j in range(4):
		string += ele
		boringApts.append(string)
while testCases > 0:
	x = input()
	dials = 0
	for apts in boringApts:
		dials += len(apts)
		if apts == x:
			break
	print(dials)
	testCases -= 1


n = int(input())
for i in range(n):
	a = input()
	len(a)
	if len(a) == 1:
		b = int(a)
		c = b // 1
		print((c - 1) * (1 + 2 + 3 + 4) + 1)
	elif len(a) == 2:
		b = int(a)
		c = b // 11
		print((c - 1) * (1 + 2 + 3 + 4) + 1 + 2)
	elif len(a) == 3:
		b = int(a)
		c = b // 111
		print((c - 1) * (1 + 2 + 3 + 4) + 1 + 2 + 3)
	elif len(a) == 4:
		b = int(a)
		c = b // 1111
		print((c - 1) * (1 + 2 + 3 + 4) + 1 + 2 + 3 + 4)


for _ in range(int(input())):
	n = input()
	arr10 = list(map(int, list(n)))
	n = int(n)
	arr = [i for i in range(1, len(arr10) + 1)]
	print(10 * (arr10[0] - 1) + sum(arr))


def solve(n):
	temp = [1, 11, 111, 1111, 2, 22, 222, 2222, 3, 33, 333, 3333, 4, 44, 444, 4444, 5, 55, 555, 5555, 6, 66, 666, 6666, 7, 77, 777, 7777, 8, 88, 888, 8888, 9, 99, 999, 9999]
	ans = []
	res = 0
	map = {1: 9, 2: 7, 3: 4, 4: 0}
	if n <= 0:
		return 0
	x = n % 10
	for i in temp:
		if i % 10 <= x:
			ans.append(i)
	for i in ans:
		res += len(str(i))
	return res - map[len(str(n))]
for _ in range(int(input())):
	n = int(input())
	print(solve(n))


T = int(input())
for _ in range(T):
	X = input()
	X0 = int(X[0])
	X_len = len(X)
	ans = (X0 - 1) * 10
	for i in range(X_len + 1):
		ans += i
	print(ans)


t = int(input())
arr = [1111, 111, 11, 1]
while t:
	x = int(input())
	for i in range(len(arr)):
		if x % arr[i] == 0:
			k = x // arr[i]
			ans = 10 * (k - 1)
			if i == 0:
				ans += 10
			elif i == 1:
				ans += 6
			elif i == 2:
				ans += 3
			else:
				ans += 1
			print(ans)
			break
	t -= 1


def calculate_character(arr):
	res = []
	for num in arr:
		val = str(num)
		length = len(val)
		sums = 0
		while length != 0:
			sums = sums + length
			length = length - 1
		res.append(sums + (int(val[0]) - 1) * 10)
	return res
t = int(input())
arr = []
result = []
for i in range(0, t):
	num = int(input())
	arr.append(num)
result = calculate_character(arr)
for num in result:
	print(num)


def main_func(x: str):
	return str(int(len(x) * (len(x) + 1) / 2 + (int(x[0]) - 1) * 10))
t = input()
r = ''
for i in range(int(t)):
	r = input()
	print(main_func(r))


import sys
input = sys.stdin.readline
for _ in range(int(input())):
	n = int(input())
	l = list(str(n))
	ans = 10 * (int(l[0]) - 1)
	if len(l) == 1:
		ans += 1
	elif len(l) == 2:
		ans += 3
	elif len(l) == 3:
		ans += 6
	elif len(l) == 4:
		ans += 10
	print(ans)


def solver(n):
	total = 0
	x = n % 10
	(nlen, temp) = (0, n)
	while temp:
		temp = int(temp / 10)
		nlen += 1
	total = 10 * (x - 1) + int(nlen * (nlen + 1) / 2)
	return total
t = int(input())
for _ in range(t):
	n = int(input())
	print(solver(n))


for _ in range(int(input())):
	n = list(map(int, input()))
	count = 0
	if n[0] == 1:
		if len(n) == 1:
			count += 1
		elif len(n) == 2:
			count += 3
		elif len(n) == 3:
			count += 6
		elif len(n) == 4:
			count += 10
	else:
		count += (n[0] - 1) * 10
		if len(n) == 1:
			count += 1
		elif len(n) == 2:
			count += 3
		elif len(n) == 3:
			count += 6
		elif len(n) == 4:
			count += 10
	print(count)


a = int(input())
vs = []
for i in range(a):
	e = input()
	vs.append(e)
for x in vs:
	r = 0
	lx = len(x)
	k = int(x[0])
	r += (k - 1) * 10
	if lx == 1:
		r += 1
	if lx == 2:
		r += 3
	if lx == 3:
		r += 6
	if lx == 4:
		r += 10
	print(r)


def boring(n):
	press = 0
	s = n[0]
	k = int(s) - 1
	if k:
		for i in range(1, k + 1):
			press += 10
	l = len(n)
	for i in range(1, l + 1):
		press += i
	return press
t = int(input())
for _ in range(t):
	n = input()
	print(boring(n))


c = int(input())
for _ in range(c):
	a = input()
	b = int(a[0]) - 1
	s = b * 10
	for i in range(1, len(a) + 1, 1):
		s += i
	print(s)


t = int(input())
for _ in range(t):
	n = int(input())
	ans = 0
	for i in range(1, 10):
		c = 1
		while True:
			num = int(str(i) * c)
			if num < 10000 and num != n:
				ans += c
			else:
				break
			c += 1
		if num == n:
			ans += c
			break
	print(ans)


for _ in range(int(input())):
	x = int(input())
	numbers = [str(i) * j for i in range(1, 10) for j in range(1, 5)]
	total = 0
	for num in numbers:
		if int(num) == x:
			total += len(num)
			break
		else:
			total += len(num)
	print(total)


arr = [1, 2, 3, 4]
for i in range(int(input())):
	x = str(input())
	ans = 10 * (int(x[0]) - 1) + sum(arr[:len(x)])
	print(ans)


t = int(input())
l = []
intl = []
final = []
for item in range(t):
	l.append(input())
ind = list(map(int, [itemi[0] for itemi in l]))
intl = [int(itema) for itema in l]
final = list(map(int, [10 * (ind[item] - 1) + len(l[item]) * (len(l[item]) + 1) / 2 for item in range(len(ind))]))
print(*final)


t = int(input())
while t > 0:
	x = int(input())
	if 0 < x < 10:
		a = 10 * (x - 1)
		print(a + 1)
	elif 10 < x < 100:
		a = 10 * (x % 10 - 1)
		print(a + 3)
	elif 100 < x < 1000:
		a = 10 * (x // 100 - 1)
		print(a + 6)
	elif 1000 < x < 10000:
		a = 10 * (x // 1000 - 1)
		print(a + 10)
	t = t - 1


for _ in range(int(input())):
	x = input()
	(n, ans) = (len(x), 0)
	while n:
		ans += n
		n -= 1
	x = int(x[0])
	ans += (x - 1) * 10
	print(ans)


for _ in range(int(input())):
	x = input()
	num = ''
	ld = 1
	ans = 0
	while num != x and ld != 10:
		num += str(ld)
		if len(num) > 4:
			ld += 1
			num = str(ld)
		ans += len(num)
	print(ans)


def R():
	return map(int, input().split())

def I():
	return int(input())
s = []
numb = ['1', '2', '3', '4', '5', '6', '7', '8', '9']
cnt = 0
for i in numb:
	for j in range(1, 5):
		cnt += j
		s.append([i * j, cnt])
d = {}
for i in range(len(s)):
	(a, b) = s[i]
	d[a] = b
for _ in range(I()):
	x = input()
	print(d[x])


from __future__ import division, print_function
import os, sys
from io import BytesIO, IOBase
if sys.version_info[0] < 3:
	from __builtin__ import xrange as range
	from future_builtins import ascii, filter, hex, map, oct, zip

def ii():
	return int(input())

def fi():
	return float(input())

def si():
	return input()

def msi():
	return map(str, input().split())

def mi():
	return map(int, input().split())

def li():
	return list(mi())

def read():
	sys.stdin = open('input.txt', 'r')
	sys.stdout = open('output.txt', 'w')

def gcd(x, y):
	while y:
		(x, y) = (y, x % y)
	return x

def lcm(x, y):
	return x * y // gcd(x, y)
mod = 1000000007

def modInverse(b, m):
	g = gcd(b, m)
	if g != 1:
		return -1
	else:
		return pow(b, m - 2, m)

def ceil(x, y):
	if x % y == 0:
		return x // y
	else:
		return x // y + 1

def modu(a, b, m):
	a = a % m
	inv = modInverse(b, m)
	if inv == -1:
		return -999999999
	else:
		return inv * a % m
from math import log, sqrt, factorial, cos, tan, sin, radians, floor
import bisect
from decimal import *
getcontext().prec = 8
abc = 'abcdefghijklmnopqrstuvwxyz'
pi = 3.141592653589793

def fun(a, n):
	s = 0
	if n == 1:
		return s
	for i in range(n):
		b = []
		b.extend(a[0:i])
		c = a[i + 1:]
		b.extend(c)
		s += fun(b, n - 1)

def isP(n):
	c = 0
	for i in range(2, int(sqrt(n)) + 1):
		if n % i == 0:
			c += 1
	if c:
		return False
	return True
pr = []
for i in range(101, 1050):
	if isP(i):
		pr.append(i)

def main():
	for _ in range(ii()):
		n = ii()
		ans = 0
		x = str(n)
		c = int(x[0])
		ans += (c - 1) * 10
		y = len(x)
		ans += y * (y + 1) // 2
		print(ans)
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')

def print(*args, **kwargs):
	(sep, file) = (kwargs.pop('sep', ' '), kwargs.pop('file', sys.stdout))
	at_start = True
	for x in args:
		if not at_start:
			file.write(sep)
		file.write(str(x))
		at_start = False
	file.write(kwargs.pop('end', '\n'))
	if kwargs.pop('flush', False):
		file.flush()
if sys.version_info[0] < 3:
	(sys.stdin, sys.stdout) = (FastIO(sys.stdin), FastIO(sys.stdout))
else:
	(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
input = lambda : sys.stdin.readline().rstrip('\r\n')
main()


answer = {}
digit_count = 0
for i in range(1, 10):
	for j in range(1, 5):
		digit_count += j
		answer[str(i) * j] = digit_count
t = int(input())
for _ in range(t):
	query = input().strip()
	print(answer[query])


num = int(input())
for i in range(num):
	numz = input()
	digitz = len(numz)
	timez = int(numz[0]) - 1
	sumz = 0
	for j in range(1, digitz + 1):
		sumz += j
	print(timez * 10 + sumz)


L = [1, 11, 111, 1111, 2, 22, 222, 2222, 3, 33, 333, 3333, 4, 44, 444, 4444, 5, 55, 555, 5555, 6, 66, 666, 6666, 7, 77, 777, 7777, 8, 88, 888, 8888, 9, 99, 999, 9999]
t = int(input())
while t:
	x = int(input())
	p = L.index(x) + 1
	q = p // 4
	r = p % 4
	nchr = q * 10 + r * (r + 1) // 2
	print(nchr)
	t -= 1


import sys
import math
import time
from functools import lru_cache
from collections import Counter
import heapq

def Update(X, AX, BX, CX, DX, k, n):
	for i in range(k, n):
		tem = (AX * X[i - 2] + BX * X[i - 1] + CX) % DX + 1
		X.append(tem)
try:
	for _ in range(int(input())):
		na = input()
		for i in range(1, 10):
			if int(na[0]) == i:
				ns = 10 * (i - 1)
				break
		y = len(na)
		if y == 1:
			print(ns + y)
		elif y == 2:
			print(ns + 3)
		elif y == 3:
			print(ns + 6)
		else:
			print(ns + 10)
except EOFError as e:
	print(e)


def countDigit(n):
	count = 0
	while n != 0:
		n //= 10
		count += 1
	return count
t = int(input())
for i in range(t):
	n = int(input())
	x = countDigit(n)
	while n >= 10:
		n = n // 10
	ans = 10 * (n - 1) + x * (x + 1) // 2
	print(ans)


def solve(d):
	(l, n) = (len(d), int(d[0]))
	return 10 * (n - 1) + l * (l + 1) // 2
for _ in range(int(input())):
	p = input()
	print(solve(p))


t = int(input())
l = []
for i in range(t):
	x = input()
	count = 0
	for j in range(1, 10):
		z = ''
		for k in range(1, 5):
			z = z + str(j)
			count += len(str(z))
			if z == x:
				l.append(int(count))
				break
for i in l:
	print(i)


n = int(input())
for i in range(n):
	x = input()
	k = int(x[0])
	m = len(x)
	print(10 * (k - 1) + m * (m + 1) // 2)


def mi():
	return map(int, input().split())
for _ in range(int(input())):
	n = int(input())
	a = []
	for i in range(1, 9 + 1):
		a = a + [i, 11 * i, 111 * i, 1111 * i]
	for i in range(len(a)):
		a[i] = list(str(a[i]))
	ans = 0
	n = list(str(n))
	for i in a:
		if n < i:
			break
		ans += len(i)
	print(ans)


for i in range(int(input())):
	l = [1, 3, 6, 10]
	x = input()
	c = int(x[0])
	d = int(x)
	print(10 * (c - 1) + l[len(x) - 1])


n = int(input())
for _ in range(n):
	k = int(input())
	r1 = len(str(k))
	s = str(k)[0:1]
	r = int(s)
	p = (r - 1) * 10 + r1 * (r1 + 1) // 2
	print(p)


t = int(input())
l = []
if t >= 1 and t <= 36:
	for i in range(t):
		x = int(input())
		if x >= 1 and x <= 9999:
			s = 0
			z = x % 10
			m = x
			c = 0
			for i in range(1, 10, 1):
				if i == z:
					break
				else:
					s = s + 10
			while m > 0:
				t = m % 10
				c += 1
				m = m // 10
			for i in range(1, c + 1, 1):
				s = s + i
			l.append(s)
for i in l:
	print(i)


def solve(n):
	base = [1, 11, 111, 1111]
	aparts = []
	for i in range(1, 10):
		aparts += [_ * i for _ in base]
	r = 0
	for e in aparts:
		r += len(str(e))
		if e == n:
			break
	return r
for _ in range(int(input())):
	n = int(input())
	r = solve(n)
	print(r)


for number in range(int(input())):
	string = input()
	length = len(string)
	num = int(string[0])
	if num > 1:
		sum = 4 * (4 + 1) / 2
		sum1 = length * (length + 1) / 2
		result = sum * (num - 1)
		print(int(result + sum1))
	else:
		sum2 = length * (length + 1) / 2
		print(int(sum2))


t = int(input())
for i in range(t):
	n = str(input())
	digit = int(n[0]) - 1
	count = n.count(n[0])
	if count == 1:
		print(digit * 10 + count)
	elif count == 2:
		print(digit * 10 + count + 1)
	elif count == 3:
		print(digit * 10 + count + 3)
	else:
		print(digit * 10 + count + 6)


for _ in range(int(input())):
	n = int(input())
	d = n % 10
	c = d - 1
	ans = c * 10
	co = 0
	while n != 0:
		co = co + 1
		n = n // 10
	a = 1
	for i in range(co):
		ans = ans + a
		a = a + 1
	print(ans)


for _ in range(int(input())):
	a = input()
	first = int(a[0])
	length = len(a)
	print((first - 1) * 10 + length * (length + 1) // 2)


t = int(input())
ints = [1, 2, 3, 4] * 9
for _ in range(t):
	x = int(input())
	intPressed = int(str(x)[0])
	total = (intPressed - 1) * 4 + len(str(x))
	print(max(1, sum(ints[0:total])))


t = int(input())
i = 0
while i < t:
	a = input()
	n = int(a[0])
	l = len(a)
	k = 10 * (n - 1)
	if l == 1:
		k += 1
	elif l == 2:
		k += 3
	elif l == 3:
		k += 6
	elif l == 4:
		k += 10
	print(k)
	i += 1


test_cases = int(input())

def calcPresses(apt):
	num = 0
	for i in range(1, len(apt) + 1):
		num += i
	num += (int(apt[0]) - 1) * 10
	return num
for _ in range(test_cases):
	cs = input()
	print(calcPresses(cs))


t = int(input())
for i in range(t):
	x = input()
	cur1 = int(x[0])
	cur2 = len(x)
	if cur2 == 3:
		cur2 = 6
	if cur2 == 2:
		cur2 = 3
	if cur2 == 4:
		cur2 = 10
	print((cur1 - 1) * 10 + cur2)


t = int(input())
for e in range(t):
	k = int(input())
	r = 0
	done = False
	for m in range(1, 10):
		for n in range(1, 5):
			z = int(str(m) * n)
			if not done and z == k:
				r += len(str(z))
				done = True
			elif not done:
				r += len(str(z))
	print(r)


a = [1, 2, 3, 4]
for _ in range(int(input())):
	n = int(input())
	k = int(str(n)[-1])
	print((k - 1) * 10 + sum(a[:len(str(n))]))


for __ in range(int(input())):
	n = input()
	ans = (int(n[0]) - 1) * 10 + 1
	if len(n) >= 2:
		ans += 2
	if len(n) >= 3:
		ans += 3
	if len(n) >= 4:
		ans += 4
	print(ans)


t = int(input())
for i in range(t):
	s = list(input())
	a = (int(s[0]) - 1) * 10
	for j in range(1, len(s) + 1):
		a += j
	print(a)


import sys
input = sys.stdin.readline

def calc(n):
	if n == 1:
		return 1
	return n + calc(n - 1)
for _ in range(int(input())):
	n = input()
	print((int(n[0]) - 1) * 10 + calc(len(n)) - len(n))


n = int(input())
d = [0, 1, 3, 6, 10]
for i in range(n):
	a = input()
	b = d[len(a)]
	c = (int(a[0]) - 1) * 10
	print(b + c)


t = int(input())
for i in range(t):
	s = str(input())
	l = len(s)
	dig = int(s[0])
	print(int(10 * (dig - 1) + l * (l + 1) / 2))


t = int(input())
aps = ['1', '11', '111', '1111', '2', '22', '222', '2222', '3', '33', '333', '3333', '4', '44', '444', '4444', '5', '55', '555', '5555', '6', '66', '666', '6666', '7', '77', '777', '7777', '8', '88', '888', '8888', '9', '99', '999', '9999']
for _ in range(t):
	x = int(input())
	resp = 0
	for ap in aps:
		resp += len(ap)
		if int(ap) == x:
			break
	print(resp)


import os
import sys
import math
import collections

def get_int():
	return int(input())

def get_ints():
	return map(int, input().split())

def get_strs():
	return input().split()

def get_float():
	return float(input())

def get_floats():
	return map(float, input().split())

def list_strs():
	return list(input().split())

def list_ints():
	return list(map(int, input().split()))

def list_floats():
	return list(map(float, input.split()))

def post(x):
	print(x, end=' ')
T = int(input())
for t in range(1, T + 1):
	x = input()
	xn = len(x)
	y = int(x[0])
	if len(x) == 4:
		print(10 * y)
	else:
		print(10 * (y - 1) + sum(range(1, xn + 1)))


def digitNum(n):
	count = 0
	while n != 0:
		count += 1
		n = n // 10
	return count

def num(x):
	a = x % 10
	b = digitNum(x)
	if b == 4:
		ans = (a - 1) * 10 + 10
	elif b == 3:
		ans = (a - 1) * 10 + 6
	elif b == 2:
		ans = (a - 1) * 10 + 3
	elif b == 1:
		ans = (a - 1) * 10 + 1
	return ans
t = int(input())
for i in range(t):
	x = int(input())
	print(num(x))


import math
from sys import stdin
from sys import setrecursionlimit
setrecursionlimit(100000)

def put():
	return map(int, stdin.readline().split())
for _ in range(int(input())):
	n = input()
	ans = 10 * (int(n[0]) - 1)
	print(ans + len(n) * (len(n) + 1) // 2)


tc = int(input())
for _ in range(tc):
	a = int(input())
	sum = 0
	b = 1
	c = 1
	i = 0
	j = 1
	while b != a:
		if b > 10000:
			c += 1
			b = c
			i = 0
			j += 1
		else:
			b = int(str(b) + str(j))
			i += 1
			sum += i
	print(sum + i + 1)


def solve(n):
	digit = n % 10
	tens = 10 * (digit - 1)
	length = len(str(n))
	units = length * (length + 1) // 2
	return tens + units

def main():
	t = int(input())
	for _ in range(t):
		n = int(input())
		answer = solve(n)
		print(answer)
main()


tc = int(input())
for i in range(tc):
	lst = [1, 2, 3, 4]
	x = int(input())
	print((x % 10 - 1) * sum(lst) + sum(lst[0:len(str(x))]))


t = int(input())
for i in range(0, t):
	num = input()
	first_digit = int(num[0])
	num_digits = (first_digit - 1) * 10
	num_length = len(num)
	if num_length == 1:
		num_digits += 1
	elif num_length == 2:
		num_digits += 3
	elif num_length == 3:
		num_digits += 6
	elif num_length == 4:
		num_digits += 10
	print(num_digits)


import sys
import os
from io import BytesIO, IOBase
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
input = lambda : sys.stdin.readline().rstrip('\r\n')
mod = 10 ** 9 + 7

def lcm(x, y):
	return x * y / gcd(x, y)

def fact(x, mod=mod):
	ans = 1
	for i in range(1, x + 1):
		ans = ans * i % mod
	return ans

def arr2D(n, m, default=0):
	return [[default for j in range(m)] for i in range(n)]

def arr3D(n, m, r, default=0):
	return [[[default for k in range(r)] for j in range(m)] for i in range(n)]

def sortDictV(x):
	return {k: v for (k, v) in sorted(x.items(), key=lambda item: item[1])}

class DSU:

	def __init__(self, length):
		self.length = length
		self.parent = [-1] * self.length

	def getParent(self, node, start):
		if node >= self.length:
			return False
		if self.parent[node] < 0:
			if start != node:
				self.parent[start] = node
			return node
		return self.getParent(self.parent[node], start)

	def union(self, node1, node2):
		parent1 = self.getParent(node1, node1)
		parent2 = self.getParent(node2, node2)
		if parent1 == parent2:
			return False
		elif self.parent[parent1] <= self.parent[parent2]:
			self.parent[parent1] += self.parent[parent2]
			self.parent[parent2] = parent1
		else:
			self.parent[parent2] += self.parent[parent1]
			self.parent[parent1] = parent2
		return True

	def getCount(self, node):
		return -self.parent[self.getParent(node, node)]

def solve(n):
	curr = '1'
	cnt = 0
	while int(curr) != n:
		cnt += len(curr)
		curr += curr[0]
		if int(curr) > 10000:
			curr = str(int(curr[0]) + 1)
	return cnt + len(str(n))
for _ in range(int(input())):
	n = int(input())
	print(solve(n))


for i in range(int(input())):
	n = int(input())
	total = 10
	s = str(n)
	if s[0] == '1':
		if n == 1:
			print(1)
		elif n == 11:
			print(3)
		elif n == 111:
			print(6)
		elif n == 1111:
			print(10)
	else:
		w = int(s[0])
		sum = 0
		for i in range(1, w):
			sum = sum + 10
		l = len(s)
		sum = sum + l * (l + 1) // 2
		print(sum)


duplicates = []
answers = []
test_cases = int(input())
for i in range(test_cases):
	answered = list(input())
	duplicates.append(4 * (int(answered[0]) - 1) + len(answered))
for j in duplicates:
	total = j // 4 * 10
	if j % 4 == 1:
		total += 1
	if j % 4 == 2:
		total += 3
	if j % 4 == 3:
		total += 6
	answers.append(total)
for k in answers:
	print(k)


t = int(input())
arr = []
for i in range(1, 10):
	for j in range(1, 5):
		arr.append(str(i) * j)
while t > 0:
	t -= 1
	ans = 0
	x = input()
	for e in arr:
		ans += len(e)
		if e == x:
			break
	print(ans)


n = int(input())
for i in range(n):
	x = int(input())
	rez = 10 * (x % 10 - 1)
	if x // 1000 != 0:
		rez = rez + 10
	elif x // 100 != 0:
		rez = rez + 6
	elif x // 10 != 0:
		rez = rez + 3
	else:
		rez = rez + 1
	print(rez)


t = int(input())
for x in range(t):
	x = input()
	first_number = x[0]
	number_of_numbers = len(x)
	digits = (int(first_number) - 1) * 10 + len(x) * (len(x) + 1) // 2
	print(digits)


for _ in range(int(input())):
	n = input()
	n3 = int(n)
	n2 = len(n)
	n1 = int(n[0]) - 1
	print(int(n1 * 10) + int(n2 * (n2 + 1) * 0.5))


for i in range(int(input())):
	x = input()
	temp = 0
	if len(x) == 4:
		temp += 10
	elif len(x) == 3:
		temp += 6
	elif len(x) == 2:
		temp += 3
	else:
		temp += 1
	first = int(x[0])
	temp += (first - 1) * 10
	print(temp)


def boaring_apartment(resident_call):
	i = 1
	k = 1
	rng = 1
	no_key_pressed = 0
	while i != resident_call:
		if i <= 10000:
			no_key_pressed += len(str(i))
		else:
			rng += 1
			i = rng
			k = 0
		if k != 0:
			i = 10 ** k * rng + i
			k += 1
		else:
			i = 10 * k * rng + i
			k += 1
	return no_key_pressed + len(str(resident_call))
n = int(input())
list = []
for i in range(n):
	list.append(int(input()))
for i in list:
	print(boaring_apartment(i))


for _ in range(int(input())):
	n = input()
	lmoa = len(n) * (len(n) + 1) // 2
	print(lmoa + 10 * (ord(n[0]) - 49))


a = []
for i in range(1, 10):
	for j in range(1, 5):
		a.append(str(i) * j)
for _ in range(int(input())):
	x = int(input())
	ans = 0
	for i in a:
		if int(i) == x:
			print(ans + len(i))
			break
		else:
			ans += len(i)


cases = [1, 11, 111, 1111, 2, 22, 222, 2222, 3, 33, 333, 3333, 4, 44, 444, 4444, 5, 55, 555, 5555, 6, 66, 666, 6666, 7, 77, 777, 7777, 8, 88, 888, 8888, 9, 99, 999, 9999]
for _ in range(int(input())):
	ans = ''
	a = int(input())
	temp = cases.index(a)
	for z in range(temp + 1):
		ans += str(cases[z])
	print(len(ans))


for _ in range(int(input())):
	x = int(input())
	y = x % 10
	total = 0
	a = 0
	while y > 1:
		total += 10
		y -= 1
	for i in range(1, len(str(x)) + 1):
		a += i
	print(total + a)


boring = []
for i in range(1, 10):
	boring.append(i)
	boring.append(int(str(i) + str(i)))
	boring.append(int(str(i) + str(i) + str(i)))
	boring.append(int(str(i) + str(i) + str(i) + str(i)))
T = int(input())
for t in range(T):
	n = int(input())
	if n in boring:
		ans = 0
		for i in boring:
			ans += len(str(i))
			if i == n:
				break
		print(ans)
	else:
		print(-1)


caseNum = int(input())
for i in range(caseNum):
	boringNum = int(input())
	a = boringNum % 10
	b = str(boringNum).__len__()
	totalNum = (a - 1) * 10
	for j in range(b):
		totalNum += j + 1
	print(totalNum)


n = int(input())
k = 1
for i in range(n):
	a = int(input())
	b = 4 * (a % 10 - 1) + len(str(a))
	ans = 0
	k = 1
	for j in range(1, b + 1):
		ans += k
		k += 1
		if k > 4:
			k = 1
	print(ans)


t = int(input())
for i in range(t):
	n = int(input())
	k = n
	a = 0
	while k > 0:
		a += 1
		k //= 10
	b = 0
	for j in range(1, a + 1):
		b += j
	print((n % 10 - 1) * 10 + b)


import typing

def rl(*args) -> typing.Iterable:
	(func, funcs) = (int, (int, float, str))
	(itr, itrs) = (iter, (iter, list, tuple))
	sep = ' '
	for a in args:
		if a in funcs:
			func = a
		elif a in itrs:
			itr = a
		elif isinstance(a, str):
			sep = a
	return itr(map(func, input().strip().split(sep)))
T = int(input())
while T:
	T -= 1
	n = int(input())
	s = str(n)
	d = int(s[0])
	print(10 * (d - 1) + sum(range(1, len(s) + 1)))


t = int(input())
cur_sum = 0
for i in range(t):
	ans = int(input())
	cur_sum = (int(str(ans)[0]) - 1) * 10 + len(str(ans)) * (len(str(ans)) + 1) // 2
	print(cur_sum)


t = int(input())
for i in range(t):
	ans = 0
	apartments = int(input())
	steps = apartments % 10
	steps -= 1
	ans += steps * 10
	length = len(str(apartments))
	ans += length * (length + 1) / 2
	print(int(ans))


cisla = [[1, 11, 111, 1111], [2, 22, 222, 2222], [3, 33, 333, 3333], [4, 44, 444, 4444], [5, 55, 555, 5555], [6, 66, 666, 6666], [7, 77, 777, 7777], [8, 88, 888, 8888], [9, 99, 999, 9999]]
n = 0
f = int(input())
while n < f:
	suma = 0
	cislo = int(input())
	for i in range(len(cisla)):
		if cislo in cisla[i]:
			for j in range(len(cisla[i])):
				if cislo == cisla[i][j]:
					suma += j + 1
					break
				else:
					suma += j + 1
			break
		else:
			suma += 10
	print(suma)
	n += 1


from sys import maxsize, stdout, stdin
mod = int(1000000000.0 + 7)

def I():
	return int(stdin.readline())

def lint():
	return [int(x) for x in stdin.readline().split()]

def S():
	return input().strip()

def grid(r, c):
	return [lint() for i in range(r)]
for _ in range(I()):
	n = input().strip()
	d = n[0]
	x = len(n)
	passed = (int(d) - 1) * 10
	ans = x * (x + 1) // 2
	print(passed + ans)


for _ in range(int(input())):
	n = int(input())
	l = [-1]
	for i in range(1, 10):
		l.extend([1 * i, 11 * i, 111 * i, 1111 * i])
	ind = l.index(n)
	ans = 10 * (ind // 4)
	val = ind - 4 * (ind // 4)
	if val == 1:
		ans += 1
	elif val == 2:
		ans += 3
	elif val == 3:
		ans += 6
	print(ans)


for l in range(int(input())):
	n = int(input())
	arr = []
	res = [1, 11, 111, 1111]
	for i in range(1, 10):
		for j in range(4):
			arr.append(i * res[j])
	ans = 0
	for k in range(91):
		if arr[k] != n:
			ans += len(str(arr[k]))
		else:
			ans += len(str(arr[k]))
			break
	print(ans)


for _ in range(int(input())):
	n = int(input())
	x = int(str(n)[0])
	v = len(str(n))
	sex = 0
	if v == 2:
		sex = 1
	if v == 3:
		sex = 3
	if v == 4:
		sex = 6
	print((x - 1) * 10 + len(str(n)) + sex)


import sys
input = sys.stdin.readline

def solve():
	t = int(input())
	for _ in range(t):
		x = input().strip()
		cur_num = ''
		digit = 1
		pressed = 0
		while cur_num != x:
			if len(cur_num) == 4:
				cur_num = ''
				digit += 1
			cur_num += str(digit)
			pressed += len(cur_num)
		print(pressed)
solve()


T = int(input())
while T > 0:
	x = int(input())
	digit = x % 10
	count = 0
	while x > 0:
		x //= 10
		count += 1
	res = 0
	res += (digit - 1) * 10
	res += (1 + count) * count // 2
	print(res)
	T -= 1


from sys import stdin, stdout

def INI():
	return int(stdin.readline())

def INL():
	return [int(_) for _ in stdin.readline().split()]

def INS():
	return stdin.readline()

def OPS(ans):
	stdout.write(str(ans) + '\n')

def OPL(ans):
	[stdout.write(str(_) + ' ') for _ in ans]
	stdout.write('\n')
for _ in range(INI()):
	n = INS()
	ans = (int(n[0]) - 1) * 10
	ans += len(n) * (len(n) - 1) // 2
	OPS(ans)


t = int(input())
l1 = [1, 11, 111, 1111, 2, 22, 222, 2222, 3, 33, 333, 3333, 4, 44, 444, 4444, 5, 55, 555, 5555, 6, 66, 666, 6666, 7, 77, 777, 7777, 8, 88, 888, 8888, 9, 99, 999, 9999]
for ind in range(t):
	broj = int(input())
	mesto_broja = l1.index(broj)
	l2 = l1[:mesto_broja + 1]
	ukupan_broj_cifara = len(l2)
	maxzbirovi = ukupan_broj_cifara // 4
	zbir = maxzbirovi * 10
	if ukupan_broj_cifara % 4 == 1:
		zbir = zbir + 1
		print(zbir)
	elif ukupan_broj_cifara % 4 == 2:
		zbir = zbir + 3
		print(zbir)
	elif ukupan_broj_cifara % 4 == 3:
		zbir = zbir + 6
		print(zbir)
	elif ukupan_broj_cifara % 4 == 0:
		print(zbir)


for _ in range(int(input())):
	x = int(input())
	ans = 10 * (x % 10 - 1)
	i = 1
	t = x % 10
	while t <= x:
		t += 10 ** i * (x % 10)
		ans += i
		i += 1
	print(ans)


output = []
suma = [1, 3, 6, 10]
for i in range(int(input())):
	x = input()
	if x[0] == '1':
		output.append(suma[len(x) - 1])
	else:
		output.append((int(x[0]) - 1) * 10 + suma[len(x) - 1])
for j in output:
	print(j)


def number_boring_flats(k: int) -> int:
	length = len(str(k))
	digit = k % 10
	return (digit - 1) * 10 + (length + 1) * length // 2
n = int(input())
for _ in range(n):
	print(number_boring_flats(int(input())))


import sys
import math
from collections import Counter
from collections import OrderedDict
from functools import reduce
sys.setrecursionlimit(10 ** 6)

def inputt():
	return sys.stdin.readline().strip()

def printt(n):
	sys.stdout.write(str(n) + '\n')

def listt():
	return [int(i) for i in inputt().split()]

def gcd(a, b):
	return math.gcd(a, b)

def lcm(a, b):
	return a * b // gcd(a, b)

def factors(n):
	return set(reduce(list.__add__, ([i, n // i] for i in range(1, int(n ** 0.5) + 1) if n % i == 0)))
t = int(inputt())
for _ in range(t):
	n = inputt()
	diff = int(n[0]) - 1
	l = len(n)
	ans = 0
	if diff != 0:
		ans = 10 * diff
	ans += l * (l + 1) // 2
	printt(ans)


data = []
for r in range(1, 10):
	string = ''
	for i in range(1, 5):
		string += str(r)
		data.append(string)
m = int(input())
res = []
for r in range(m):
	cont = 0
	i = 0
	u = input()
	while data[i] != u:
		cont += len(data[i])
		i += 1
	res.append(cont + len(u))
for v in res:
	print(v)


for i in range(int(input())):
	n = int(input())
	a = 0
	m = 10 * (n % 10 - 1)
	for j in range(1, len(str(n)) + 1):
		a = a + int(j)
	print(m + a)


import sys

def Ints():
	return map(int, sys.stdin.readline().strip().split())

def Strs():
	return map(str, sys.stdin.readline().strip().split())

def Array():
	return list(map(int, sys.stdin.readline().strip().split()))

def Str():
	return sys.stdin.readline().strip()

def Int():
	return int(sys.stdin.readline().strip())

def MOD():
	return 1000000007
t = Int()
while t:
	n = Str()
	sums = 0
	flag = False
	for i in range(1, 10):
		temp = ''
		for j in range(1, 5):
			temp += str(i)
			sums += len(temp)
			if temp == n:
				flag = True
				break
		if flag:
			break
	print(sums)
	t -= 1


for _ in range(int(input())):
	x = list(input())
	di = x[0]
	le = len(x)
	ans = (int(di) - 1) * 10 + le * (le + 1) // 2
	print(ans)


for t in range(int(input())):
	x = input()
	p = int(x[0])
	l = len(x)
	k = [1, 2, 3, 4]
	print((p - 1) * 10 + sum(k[:l]))


t = int(input())
for i in range(t):
	b = int(input())
	fac = {1: 1, 2: 3, 3: 6, 4: 10, 5: 15, 6: 21, 7: 28, 8: 36, 9: 45}
	x = int(str(b)[0])
	ans = (x - 1) * fac[4] + fac[len(str(b))]
	print(ans)


T = int(input())
for k in range(0, T):
	X = input()
	a = len(X)
	b = int(a * (a + 1) / 2)
	x = int(X[0])
	if x == 1:
		print(b)
	elif x == 2:
		print(b + 10)
	elif x == 3:
		print(b + 20)
	elif x == 4:
		print(b + 30)
	elif x == 5:
		print(b + 40)
	elif x == 6:
		print(b + 50)
	elif x == 7:
		print(b + 60)
	elif x == 8:
		print(b + 70)
	elif x == 9:
		print(b + 80)


try:
	for _ in range(int(input())):
		t = int(input())
		a = str(t)
		z = (int(a[0]) - 1) * 10
		x = len(a)
		y = x ** 2 + x
		y = y / 2
		print(int(z + y))
except:
	pass


t = int(input())
for i in range(t):
	n = int(input())
	s = ''
	s = str(n)
	x = 10
	n1 = len(s)
	z = int(s[0])
	ans = (z - 1) * 10
	if len(s) == 1:
		print(ans + 1)
	if len(s) == 2:
		print(ans + 3)
	if len(s) == 3:
		print(ans + 6)
	if len(s) == 4:
		print(ans + 10)


from sys import stdin, stdout
import math, bisect
from collections import Counter, deque, defaultdict
L = lambda : list(map(int, stdin.readline().strip().split()))
M = lambda : map(int, stdin.readline().strip().split())
I = lambda : int(stdin.readline().strip())
S = lambda : stdin.readline().strip()
C = lambda : stdin.readline().strip().split()

def pr(a):
	return ' '.join(list(map(str, a)))

def solve():
	s = S()
	n = len(s)
	x = int(s[0])
	print(10 * (x - 1) + n * (n + 1) // 2)
for _ in range(I()):
	solve()


t = int(input())
while t != 0:
	t -= 1
	ans = 10
	re = 0
	x = input()
	n = len(x)
	chk = int(x[0])
	if chk - 1 == 0:
		re = n * (n + 1) // 2
	else:
		re += ans * (chk - 1)
		re += n * (n + 1) // 2
	print(re)


t = int(input())
data = []
flats = []
for num in range(1, 10):
	for reps in range(1, 5):
		flats.append(str(num) * reps)
for _ in range(t):
	data.append(input())
for _ in data:
	index = flats.index(_)
	keys = 0
	for i in range(index + 1):
		keys += len(flats[i])
	print(keys)


for i in range(int(input())):
	a = str(int(input()))
	if len(a) == 4:
		d = 10
	elif len(a) == 3:
		d = 6
	elif len(a) == 2:
		d = 3
	elif len(a) == 1:
		d = 1
	x = (int(a[0]) - 1) * 10
	print(x + d)


def boring(num):
	cnt = 0
	level = num % 10
	cnt += (level - 1) * 10
	for i in range(1, len(str(num)) + 1):
		cnt += i
	return cnt
import sys
t = int(sys.stdin.readline())
for _ in range(t):
	n = int(sys.stdin.readline())
	print(boring(n))


for i in range(int(input())):
	a = input()
	b = dict()
	for i in range(1, 10):
		b[str(i) * 1] = 1
		b[str(i) * 2] = 2
		b[str(i) * 3] = 3
		b[str(i) * 4] = 4
	suma = 0
	for i in b:
		if i == a:
			suma += b[i]
			break
		else:
			suma += b[i]
	print(suma)


t = int(input())
for _ in range(t):
	n = input()
	k = int(n[0]) - 1
	s = 10 * k
	l = len(n)
	if l == 1:
		print(s + 1)
	elif l == 2:
		print(s + 3)
	elif l == 3:
		print(s + 6)
	elif l == 4:
		print(s + 10)


T = int(input())
for t in range(T):
	ans = 0
	a = list(input())
	ans = 10 * (int(a[0]) - 1) + len(a) * (len(a) + 1) / 2
	print('{}'.format(int(ans)))


for n in range(int(input())):
	entry = input()
	x = int(entry[0])
	l = len(entry)
	L = [1, 3, 6, 10]
	r = 10 * (x - 1) + L[l - 1]
	print(r)


n = int(input())
l = []
c = 0
for x in range(n):
	x = input()
	l.append(x)
res = []
s = 10
for i in l:
	le = len(i)
	if i[0] == '1':
		s = 0
	else:
		s = s * (int(i[0]) - 1)
	for j in range(le):
		o = i[0]
		if int(o) == 1:
			s = s + (j + 1)
		else:
			s = s + (j + 1)
	res.append(s)
	s = 10
for i in range(len(res)):
	print(res[i])


import sys
from collections import defaultdict as dd
from collections import Counter as cc
from queue import Queue
import math
import itertools
try:
	sys.stdin = open('input.txt', 'r')
	sys.stdout = open('output.txt', 'w')
except:
	pass
for _ in range(int(input())):
	q = input()
	w = int(q[0]) - 1
	e = w * 10
	r = len(q)
	e += r * (r + 1) // 2
	print(e)


t = int(input())
for _ in range(t):
	n = input()
	l = ['1', '1' * 2, '1' * 3, '1' * 4, '2', '2' * 2, '2' * 3, '2' * 4, '3', '3' * 2, '3' * 3, '3' * 4, '4', '4' * 2, '4' * 3, '4' * 4, '5', '5' * 2, '5' * 3, '5' * 4, '6', '6' * 2, '6' * 3, '6' * 4, '7', '7' * 2, '7' * 3, '7' * 4, '8', '8' * 2, '8' * 3, '8' * 4, '9', '9' * 2, '9' * 3, '9' * 4]
	x = l.index(n)
	s = 0
	for i in l[:x + 1]:
		s += len(i)
	print(s)


from sys import stdin, stdout
from math import ceil, floor, factorial, gcd, log, pi
from collections import deque, defaultdict, OrderedDict, Counter
import random
import itertools
from heapq import heapify, heappush, heappop
INTEGER_MAX_VALUE = float('inf')
INTEGER_MIN_VALUE = float('-inf')
MOD = 10 ** 9 + 7

def readInt():
	return int(stdin.readline())

def readInts():
	return map(int, stdin.readline().strip().split())

def readString():
	return stdin.readline()

def readStrings():
	return map(str, stdin.readline().strip().split())

def readIntArray():
	return list(map(int, stdin.readline().strip().split()))

def readStrArray():
	return list(map(str, stdin.readline().strip().split()))

def constructMinHeap(nums, n):
	minHeap = []
	for num in nums:
		heappush(minHeap, num)
	return minHeap

def constructMaxHeap(nums, n):
	maxHeap = []
	for num in nums:
		heappush(maxHeap, -num)
	return maxHeap

def solve(x):
	current = x % 10
	answer = 0
	while current > 1:
		answer += 10
		current -= 1
	if x >= 1 and x <= 9:
		answer += 1
	elif x >= 11 and x <= 99:
		answer += 3
	elif x >= 111 and x <= 999:
		answer += 6
	else:
		answer += 10
	return answer
testCases = readInt()
for case in range(testCases):
	x = readInt()
	print(solve(x))


t = int(input())
arr_i = []
for i in range(t):
	arr_i.append(int(input()))
for j in arr_i:
	p = j % 10
	dig = (p - 1) * 10
	if 0 < j < p * 10:
		print(dig + 1)
	elif p * 10 < j < p * 100:
		print(dig + 3)
	elif p * 100 < j < p * 1000:
		print(dig + 6)
	else:
		print(dig + 10)


def solve(n):
	ans = (int(str(n)[0]) - 1) * 10
	if len(str(n)) == 1:
		return ans + 1
	elif len(str(n)) == 2:
		return ans + 3
	elif len(str(n)) == 3:
		return ans + 6
	else:
		return ans + 10
for i in range(int(input())):
	print(solve(int(input())))


l = [1, 2, 3, 4]
for _ in range(int(input())):
	n = int(input())
	length = len(str(n))
	ans = 10 * (int(str(n)[0]) - 1)
	for i in range(length):
		ans += l[i]
	print(ans)


test = int(input())
for _ in range(test):
	n = input()
	v = (int(n[0]) - 1) * 10
	if len(n) == 1:
		v += 1
	elif len(n) == 2:
		v += 3
	elif len(n) == 3:
		v += 6
	else:
		v += 10
	print(v)


for _ in range(int(input())):
	answered = input()
	char_num = int(answered[0])
	char_len = len(answered)
	res = (char_num - 1) * 10
	res += char_len * (char_len + 1) // 2
	print(res)


test_cases = int(input())
for i in range(test_cases):
	x = input()
	times = int(x[-1]) - 1
	s1 = 10 * times
	n2 = len(x)
	s2 = n2 * (n2 + 1) // 2
	print(s1 + s2)


a = []
for d in range(1, 10):
	a.append(d)
	a.append(d * 11)
	a.append(d * 111)
	a.append(d * 1111)
t = int(input())
for i in range(t):
	x = int(input())
	ans = 0
	for j in a:
		ans += len(str(j))
		if x == j:
			break
	print(ans)


test = int(input())
for _ in range(test):
	a = input()
	n = int(a[0])
	l = len(a)
	ans = (n - 1) * 10
	for i in range(l + 1):
		ans += i
	print(ans)


import sys
input = sys.stdin.buffer.readline

def solution():
	n = int(input())
	x = n % 10
	l = 0
	while n > 0:
		n //= 10
		l += 1
	ans = (x - 1) * 10
	ans += l * (l + 1) // 2
	print(ans)
t = int(input())
for _ in range(t):
	solution()


for _i in range(int(input())):
	n = input()
	s = int(n[-1])
	a = len(n)
	b = (s - 1) * 10 + a * (a + 1) / 2
	print(int(b))


for t in range(int(input())):
	n = input()
	count = 0
	count += 10 * (int(n[0]) - 1)
	if len(n) == 1:
		print(count + 1)
	if len(n) == 2:
		print(count + 3)
	if len(n) == 3:
		print(count + 6)
	if len(n) == 4:
		print(count + 10)


n = int(input())
while n:
	n -= 1
	d = int(input())
	s = (d % 10 - 1) * 10
	if d // 1000:
		s += 10
		d = d % 1000
	elif d // 100:
		s += 6
		d = d % 100
	elif d // 10:
		s += 3
	else:
		s += 1
	print(s)


for _ in range(int(input())):
	n = int(input())
	val = str(n)
	dict = {1: 1, 2: 3, 3: 6, 4: 10}
	if n == 1:
		print(1)
	elif n == 11:
		print(3)
	elif n == 111:
		print(6)
	elif n == 1111:
		print(10)
	else:
		print((int(val[0]) - 1) * 10 + dict[len(val)])


def call_me(x, m, first):
	first = int(first)
	x = int(x)
	pre = [1, 3, 6, 10]
	(i, y) = (1, 0)
	while i <= first:
		if i == first:
			y = y + pre[len(m) - 1]
		else:
			y = y + pre[-1]
		i = i + 1
	return y

def main():
	t = int(input())
	while t > 0:
		x = int(input())
		m = str(x)
		first = m[0]
		y = call_me(x, m, first)
		print(y)
		t = t - 1
main()


from math import ceil, floor, gcd, fabs, factorial, fmod, sqrt, inf
from fractions import Fraction
from decimal import Decimal
import math
mod = pow(10, 9) + 7

def sp():
	return map(int, input().split())

def lit():
	return list(sp())

def fun(x):
	return sum((int(i) for i in str(x)))

def find(n):
	if n == 3:
		return 3
	while 1:
		flag = 0
		for i in range(2, int(sqrt(n)) + 1):
			if n % i == 0:
				n += 1
				break
			if i == int(sqrt(n)):
				flag = 1
				break
		if flag:
			break
	return n
t = int(input())
for _ in range(t):
	n = int(input())
	l = [1, 11, 111, 1111, 2, 22, 222, 2222, 3, 33, 333, 3333, 4, 44, 444, 4444, 5, 55, 555, 5555, 6, 66, 666, 6666, 7, 77, 777, 7777, 8, 88, 888, 8888, 9, 99, 999, 9999]
	cnt = 0
	moves = [1, 2, 3, 4]
	j = 0
	for i in range(len(l)):
		cnt += moves[j]
		j += 1
		j = j % 4
		if l[i] == n:
			print(cnt)


import posixpath
t = int(input())
x = []
for i in range(t):
	x.append(int(input()))
res = []
for i in range(t):
	r = (x[i] % 10 - 1) * 10 + 1
	if x[i] > 10:
		r += 2
	if x[i] > 100:
		r += 3
	if x[i] > 1000:
		r += 4
	res.append(r)
for el in res:
	print(el)


from sys import stdin
tt = int(stdin.readline())
a = [0, 1, 3, 6, 10]
ans = []
for loop in range(tt):
	x = int(stdin.readline())
	ans.append((x % 10 - 1) * 10 + a[len(str(x))])
print('\n'.join(map(str, ans)))


import sys, math

def ii():
	return int(input())

def mii():
	return map(int, input().split())

def lmii():
	return list(mii())

def dtob(n):
	return bin(n).replace('0b', '')

def main():
	for _ in range(ii()):
		n = ii()
		ans = 0
		ls = [1, 3, 6, 10]
		s = str(n)
		ans += (int(s[0]) - 1) * 10
		ans += ls[len(s) - 1]
		print(ans)
main()


for h in range(int(input())):
	a = input()
	b = int(a)
	if b == 1:
		print(1)
	else:
		a = int(a[0])
		c = (a - 1) * 10
		n = str(a)
		i = 1
		while 1:
			s = n * i
			y = int(s)
			if y <= b:
				c = c + len(s)
				i = i + 1
			else:
				break
		print(c)


for i in range(int(input())):
	n = int(input())
	l1 = list(str(n))
	yo = len(l1)
	l = n % 10
	s = 0
	total = 10
	for i in range(1, l):
		s += 1
	stotal = s * 10
	de = 0
	for i in range(1, yo + 1):
		de += i
	print(de + stotal)


def number_length(x):
	l = 0
	while x:
		x //= 10
		l += 1
	return l

def increase_number(current_phone_number, greatest_flat_number):
	phone_number_digit = current_phone_number % 10
	next_phone_number = current_phone_number * 10 + phone_number_digit
	if next_phone_number > greatest_flat_number:
		next_phone_number = phone_number_digit + 1
	return next_phone_number

def count_phone_calls_keys_pressed(lowest_flat_number, greatest_flat_number, responsed_flat_number):
	starting_phone_number = 1
	current_phone_number = starting_phone_number
	while current_phone_number < lowest_flat_number:
		current_phone_number = increase_number(current_phone_number, greatest_flat_number)
	keys_pressed = number_length(current_phone_number)
	while current_phone_number != responsed_flat_number:
		current_phone_number = increase_number(current_phone_number, greatest_flat_number)
		keys_pressed += number_length(current_phone_number)
	return keys_pressed

def process_tests(tests_count, lowest_flat_number, greatest_flat_number):
	for i in range(tests_count):
		print(count_phone_calls_keys_pressed(lowest_flat_number, greatest_flat_number, int(input())))
process_tests(int(input()), 1, 10000)


t = int(input())
c = []
for i in range(t):
	x = int(input())
	a = [1, 11, 111, 1111, 2, 22, 222, 2222, 3, 33, 333, 3333, 4, 44, 444, 4444, 5, 55, 555, 5555, 6, 66, 666, 6666, 7, 77, 777, 7777, 8, 88, 888, 8888, 9, 99, 999, 9999]
	b = a.index(x) + 1
	ans = b // 4 * 10
	if b % 4 == 1:
		ans += 1
	elif b % 4 == 2:
		ans += 3
	elif b % 4 == 0:
		ans += 0
	else:
		ans += 6
	c.append(ans)
for i in range(len(c)):
	print(c[i])


t = int(input())
ans = []
for i in range(t):
	x = int(input())
	s = 10 * (x % 10 - 1)
	k = 1
	while x > 0:
		x //= 10
		s += k
		k += 1
	ans.append(s)
for i in ans:
	print(i)


T = int(input())
X = []
for i in range(1, 10):
	for j in range(1, 5):
		t = str(i) * j
		t = int(t)
		X.append((t, j))
for _ in range(T):
	x = int(input())
	ans = 0
	for (t, j) in X:
		ans += j
		if t == x:
			print(ans)
			break


t = int(input())
for ggwp in range(t):
	a = int(input())
	sc = 0
	g = '0'
	j = g * 1
	t = True
	while t == True:
		g = str(int(g) + 1)
		for i in range(1, 5):
			if int(j) == a:
				sc += len(j)
				print(sc - 1)
				t = False
				break
			else:
				sc += len(j)
			j = g * i


t = int(input())
for q in range(t):
	a = int(input())
	x = a % 10
	y = len(str(a))
	print((x - 1) * 10 + y * (y + 1) // 2)


t = int(input())
for i in range(t):
	x = int(input())
	m = x % 10
	n = len(str(x))
	s = (m - 1) * 10 + (1 + n) * n // 2
	print(s)


import sys
input = sys.stdin.readline

def solve():
	n = int(input())
	li = []
	for i in range(1, 10):
		total = 0
		for j in range(4):
			val = 10 ** j
			total += val * i
			li.append(total)
	pos = li.index(n) + 1
	(q, r) = divmod(pos, 4)
	ans = 10 * q + r * (r + 1) // 2
	print(ans)
for _ in range(int(input())):
	solve()


rr = lambda : input().strip()
rri = lambda : int(rr())
rrm = lambda : [int(x) for x in rr().split()]
from sys import stdin, stdout, setrecursionlimit
from math import ceil
from heapq import *

def sol():
	n = rr()
	res = 0
	x = ord(n[0]) - ord('0') - 1
	res = 10 * x
	y = len(n)
	y = y * (y + 1) // 2
	res += y
	print(res)
	return

def main():
	T = rri()
	for t in range(1, T + 1):
		ans = sol()
main()


for t in range(int(input())):
	x = int(input())
	n = x % 10
	r = 0
	if x < 10:
		r = 1
	if x < 100 and x > 10:
		r = 3
	if x < 1000 and x > 100:
		r = 6
	if x < 10000 and x > 1000:
		r = 10
	print((n - 1) * 10 + r)


import os, sys
from io import IOBase, BytesIO
py2 = round(0.5)
if py2:
	from future_builtins import ascii, filter, hex, map, oct, zip
	range = xrange
BUFSIZE = 8192

class FastIO(BytesIO):
	newlines = 0

	def __init__(self, file):
		self._file = file
		self._fd = file.fileno()
		self.writable = 'x' in file.mode or 'w' in file.mode
		self.write = super(FastIO, self).write if self.writable else None

	def _fill(self):
		s = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
		self.seek((self.tell(), self.seek(0, 2), super(FastIO, self).write(s))[0])
		return s

	def read(self):
		while self._fill():
			pass
		return super(FastIO, self).read()

	def readline(self):
		while self.newlines == 0:
			s = self._fill()
			self.newlines = s.count(b'\n') + (not s)
		self.newlines -= 1
		return super(FastIO, self).readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.getvalue())
			(self.truncate(0), self.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		if py2:
			self.write = self.buffer.write
			self.read = self.buffer.read
			self.readline = self.buffer.readline
		else:
			self.write = lambda s: self.buffer.write(s.encode('ascii'))
			self.read = lambda : self.buffer.read().decode('ascii')
			self.readline = lambda : self.buffer.readline().decode('ascii')
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
input = lambda : sys.stdin.readline().rstrip('\r\n')
import sys

class ostream:

	def __lshift__(self, a):
		sys.stdout.write(str(a))
		return self
cout = ostream()
endl = '\n'

def get_input(a=str):
	return a(input())

def get_int_input():
	return get_input(int)

def get_input_arr(a):
	return list(map(a, input().split()))

def get_int_input_arr():
	return get_input_arr(int)

def solve():
	t = get_int_input()
	for _ in range(t):
		num_str = get_input()
		res = 0
		c = int(num_str[0])
		res += 10 * (c - 1)
		res += len(num_str) * (len(num_str) + 1) // 2
		cout << res << endl

def main():
	solve()
main()


f = int(input())
for i in range(f):
	a = input()
	a1 = list(a)
	x = a1[0]
	y = a.count(x)
	x = int(x)
	if y == 1:
		print((x - 1) * 10 + 1)
	elif y == 2:
		print((x - 1) * 10 + 3)
	elif y == 3:
		print((x - 1) * 10 + 6)
	elif y == 4:
		print(x * 10)


n = int(input())
for i in range(n):
	x = int(input())
	a = x % 10
	b = 10 * (a - 1)
	length = len(str(x))
	if length == 1:
		b += 1
	if length == 2:
		b += 3
	if length == 3:
		b += 6
	if length == 4:
		b += 10
	print(b)


import math
t = int(input())
for k1 in range(t):
	n = int(input())
	nums = [1, 11, 111, 1111, 2, 22, 222, 2222, 3, 33, 333, 3333, 4, 44, 444, 4444, 5, 55, 555, 5555, 6, 66, 666, 6666, 7, 77, 777, 7777, 8, 88, 888, 8888, 9, 99, 999, 9999]
	total = 0
	for j in nums:
		total += len(str(j))
		if j == n:
			print(total)
			break


tc = int(input())
re = []
for i in range(tc):
	s = input()
	l = len(s)
	fir = int(s[0])
	ans = (fir - 1) * 10
	if l == 1:
		ans += 1
	elif l == 2:
		ans += 3
	elif l == 3:
		ans += 6
	elif l == 4:
		ans += 10
	print(ans)


for k in range(int(input())):
	x = int(input())
	presses = [1, 3, 6, 10]
	flatNumber = (int(x % 10) - 1) * 4 + int(len(str(x)))
	total = (int(x % 10) - 1) * 10 + presses[int(len(str(x))) - 1]
	print(total)


from sys import stdin
from sys import stdout
import math
import io, os

def solve(string):
	pre_sum = [1, 3, 6, 10]
	return pre_sum[len(string) - 1] + 10 * (int(string[0]) - 1)
for _ in range(int(input())):
	string = input()
	print(solve(string))


t = int(input())
for _ in range(t):
	x = int(input())
	y1 = str(x)
	y2 = y1[0]
	a = 10 * (int(y2) - 1)
	n = len(y1)
	c = n * (n + 1) / 2
	b = c + a
	print(int(b))


x = int(input())
y = []
for i in range(x):
	y.append(int(input()))
ans = []
for i in y:
	i = str(i)
	m = i[0]
	sm = 10 * (int(m) - 1)
	for t in range(len(i), 0, -1):
		sm += t
	ans.append(sm)
for i in ans:
	print(i)


def solve():
	x = input()
	y = int(x) % 10 - 1
	ans = 10 * y
	n = len(x)
	ans += n * (n + 1) >> 1
	print(ans)
for _ in range(int(input())):
	solve()


def solve(stop):
	cnt = 0
	for c in [*'123456789']:
		s = ''
		while len(s) < 5:
			cnt += len(s)
			if s == stop:
				return cnt
			s += c
	return cnt
t = int(input().split()[0])
for i in range(t):
	n = input()
	print(solve(n))


from functools import lru_cache

def gen():
	for i in range(1, 10):
		i = str(i)
		for j in range(1, 5):
			yield (j * i)

@lru_cache(None)
def solve(n):
	digs = 0
	for num in gen():
		digs += len(num)
		if num == n:
			return digs
t = int(input())
for _ in range(t):
	n = input()
	s = solve(n)
	print(s)


t = int(input())
apt = []
for _ in range(t):
	apt.append(int(input()))

def digits(n):
	s = str(n)
	ans = int()
	for i in range(1, int(s[0]) + 1):
		for j in range(1, 5):
			if i == int(s[0]):
				if j <= len(s):
					ans += j
			else:
				ans += j
	return ans
for x in apt:
	print(digits(x))


t = int(input())
l = []
for i in range(9):
	for j in range(4):
		s = str(i + 1) * (j + 1)
		l.append(int(s))
for i in range(t):
	x = int(input())
	index = l.index(x)
	q = 0
	for j in range(index + 1):
		q = q + len(str(l[j]))
	print(q)


t = int(input())
while t:
	x = int(input())
	cnt = 0
	temp = x
	while temp > 0:
		temp //= 10
		cnt += 1
	digit = x % 10
	ans = 0
	ans += (digit - 1) * 10
	ans += cnt * (cnt + 1) // 2
	print(ans)
	t -= 1


from __future__ import division, print_function
from fractions import Fraction
import sys
import os
from io import BytesIO, IOBase
from heapq import *
from math import gcd, factorial, floor, ceil
from copy import deepcopy
from collections import deque
from bisect import bisect_left as bl
from bisect import bisect_right as br
from bisect import bisect
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')

def print(*args, **kwargs):
	(sep, file) = (kwargs.pop('sep', ' '), kwargs.pop('file', sys.stdout))
	at_start = True
	for x in args:
		if not at_start:
			file.write(sep)
		file.write(str(x))
		at_start = False
	file.write(kwargs.pop('end', '\n'))
	if kwargs.pop('flush', False):
		file.flush()
if sys.version_info[0] < 3:
	(sys.stdin, sys.stdout) = (FastIO(sys.stdin), FastIO(sys.stdout))
else:
	(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
from types import GeneratorType

def iterative(f, stack=[]):

	def wrapped_func(*args, **kwargs):
		if stack:
			return f(*args, **kwargs)
		to = f(*args, **kwargs)
		while True:
			if type(to) is GeneratorType:
				stack.append(to)
				to = next(to)
				continue
			stack.pop()
			if not stack:
				break
			to = stack[-1].send(to)
		return to
	return wrapped_func
mod = 10 ** 9 + 7

def inp():
	return sys.stdin.readline().rstrip('\r\n')

def out(var):
	sys.stdout.write(str(var))

def lis():
	return list(map(int, inp().split()))

def stringlis():
	return list(map(str, inp().split()))

def sep():
	return map(int, inp().split())

def strsep():
	return map(str, inp().split())

def zerolist(n):
	return [0] * n

def nextline():
	out('\n')

def testcase(t):
	for pp in range(t):
		solve(pp)

def printlist(a):
	for p in range(0, len(a)):
		out(str(a[p]) + ' ')

def google(p):
	print('Case #' + str(p) + ': ', end='')

def lcm(a, b):
	return a * b // gcd(a, b)

def power(x, y, p):
	res = 1
	x = x % p
	if x == 0:
		return 0
	while y > 0:
		if y & 1 == 1:
			res = res * x % p
		y = y >> 1
		x = x * x % p
	return res

def ncr(n, r):
	return factorial(n) // (factorial(r) * factorial(max(n - r, 1)))

def isPrime(n):
	if n <= 1:
		return False
	if n <= 3:
		return True
	if n % 2 == 0 or n % 3 == 0:
		return False
	i = 5
	while i * i <= n:
		if n % i == 0 or n % (i + 2) == 0:
			return False
		i = i + 6
	return True
inf = pow(10, 20)

def solve(case):
	n = inp()
	f = int(n[0])
	ans = 10 * (f - 1)
	for i in range(len(n)):
		ans += i + 1
	print(ans)
testcase(int(inp()))


import sys
import math
import heapq
from collections import defaultdict as dd
from itertools import permutations as pp
from itertools import combinations as cc
from sys import stdin
from functools import cmp_to_key
input = stdin.readline
m = 10 ** 9 + 7
sys.setrecursionlimit(10 ** 5)
T = int(input())
for _ in range(T):
	n = int(input())
	d = 0
	while n:
		d += 1
		num = n % 10
		n //= 10
	ans = 10 * (num - 1)
	for i in range(d):
		ans += i + 1
	print(ans)


t = int(input())
while t != 0:
	n = int(input())
	s = str(n)
	ans = 0
	ans += 10 * (int(s[0]) - 1)
	print(ans + len(s) * (len(s) + 1) // 2)
	t -= 1


t = int(input(''))
l1 = []
for i in range(t):
	s = input('')
	l = len(s)
	if l == 1:
		temp1 = 1
	elif l == 2:
		temp1 = 3
	elif l == 3:
		temp1 = 6
	else:
		temp1 = 10
	temp = int(s[0])
	l1.append((temp - 1) * 10 + temp1)
print(*l1, sep='\n')


t = int(input())
for _ in range(t):
	n = int(input())
	res = 0
	while n > 10:
		res += 1
		n = n // 10
	print((n - 1) * 10 + (res + 1) * (res + 2) // 2)


import sys
import math

def countDigit(n):
	return math.floor(math.log(n, 10) + 1)

def boring_apartment(num):
	calculative_num = num % 10 - 1
	rest_num = calculative_num * 10
	if countDigit(num) == 4:
		return rest_num + 10
	if countDigit(num) == 3:
		return rest_num + 6
	if countDigit(num) == 2:
		return rest_num + 3
	if countDigit(num) == 1:
		return rest_num + 1
num_test = input()
for i in range(0, int(num_test)):
	inpt = input()
	print(boring_apartment(int(inpt)))


import sys
import math
import collections
import operator as op
from collections import deque
from math import gcd, inf, sqrt, pi, cos, sin, ceil, log2, floor
from bisect import bisect_right, bisect_left, bisect
from functools import reduce
from sys import stdin, stdout, setrecursionlimit
setrecursionlimit(2 ** 20)

def ncr(n, r):
	r = min(r, n - r)
	numer = reduce(op.mul, range(n, n - r, -1), 1)
	denom = reduce(op.mul, range(1, r + 1), 1)
	return numer // denom

def prime_factors(n):
	i = 2
	factors = []
	while i * i <= n:
		if n % i:
			i += 1
		else:
			n //= i
			factors.append(i)
	if n > 1:
		factors.append(n)
	return list(factors)

def sumDigits(no):
	return 0 if no == 0 else int(no % 10) + sumDigits(int(no / 10))
MOD = 1000000007
PMOD = 998244353
N = 10 ** 9 + 7
LOGN = 30
T = 1
T = int(stdin.readline())
for _ in range(T):
	n = int(stdin.readline())
	arr = [1, 11, 111, 1111, 2, 22, 222, 2222, 3, 33, 333, 3333, 4, 44, 444, 4444, 5, 55, 555, 5555, 6, 66, 666, 6666, 7, 77, 777, 7777, 8, 88, 888, 8888, 9, 99, 999, 9999]
	ans = 0
	for i in range(len(arr)):
		ans += len(str(arr[i]))
		if arr[i] == n:
			break
	print(ans)


t = int(input())
for z in range(t):
	n = int(input())
	ans = 0
	ans += 10 * (n % 10 - 1)
	if n // 1000 > 0:
		ans += 10
	elif n // 100 > 0:
		ans += 6
	elif n // 10 > 0:
		ans += 3
	else:
		ans += 1
	print(ans)


def solve():
	temp = int(input())
	return int((temp % 10 - 1) * 10 + len(str(temp)) * (len(str(temp)) + 1) / 2)
for i in range(int(input())):
	print(solve())


def Resh(n):
	leng = 1
	result = (n - 1) % 10 * 10
	if n // 1000 > 0:
		leng = 4
	elif n // 100 > 0:
		leng = 3
	elif n // 10 > 0:
		leng = 2
	else:
		leng = 1
	for i in range(1, leng + 1):
		result += i
	return result
t = int(input())
a = []
for i in range(0, t):
	b = int(input())
	a.append(Resh(b))
for i in range(t):
	print(a[i])


def main():
	for t in range(ri()):
		s = rs()
		ans = 0
		ans += (int(s[0]) - 1) * 10
		ans += len(s) * (len(s) + 1) // 2
		print(ans)
import sys
inp = sys.stdin.buffer.readline
rl = lambda : list(map(int, inp().split()))
ri = lambda : int(inp())
rs = lambda : inp().decode().strip()
main()


t = int(input())
for x in range(t):
	k = int(input())
	l = 0
	rem = k % 10
	out = 10 * (rem - 1)
	while k != 0:
		k = int(k / 10)
		l = l + 1
	out = out + int(l * (l + 1) / 2)
	print(out)


for _ in range(int(input())):
	plus = {1: 1, 2: 3, 3: 6, 4: 10}
	current = input()
	answer = (int(current[0]) - 1) * 10 + plus[len(current)]
	print(answer)


t = int(input())
for i in range(t):
	n = input()
	a = len(n)
	b = int(n[0])
	q = 0
	for i in range(1, a + 1):
		q += i
	print((b - 1) * 10 + q)


from math import log, sqrt, factorial, cos, tan, sin, radians

def li():
	return list(map(int, input().split()))

def ii():
	return int(input())

def si():
	return input()

def mi():
	return map(int, input().split())

def ncr(n, r):
	return factorial(n) // (factorial(r) * factorial(max(n - r, 1)))

def DtoB(n):
	return bin(n).replace('0b', '')

def gcd(x, y):
	while y:
		(x, y) = (y, x % y)
	return x

def powerMod(x, y, p):
	res = 1
	x %= p
	while y > 0:
		if y & 1:
			res = res * x % p
		y = y >> 1
		x = x * x % p
	return res

def isPrime(n):
	if n <= 1:
		return False
	if n <= 3:
		return True
	if n % 2 == 0 or n % 3 == 0:
		return False
	i = 5
	while i * i <= n:
		if n % i == 0 or n % (i + 2) == 0:
			return False
		i = i + 6
	return True

def ceil(x, y):
	if x % y == 0:
		return x // y
	else:
		return x // y + 1
mod = 1000000007
l = []
for i in range(1, 10):
	for j in range(1, 5):
		l.append(str(i) * j)
for _ in range(ii()):
	n = ii()
	cn = 0
	for i in range(36):
		cn += len(l[i])
		if str(n) == l[i]:
			break
	print(cn)


import re
for i in range(int(input())):
	x = int(input())
	z = []
	for i in range(1, 10):
		for j in range(1, 5):
			z.append(str(i) * j)
	ans = 0
	for i in z:
		ans += len(i)
		if int(i) == x:
			break
	print(ans)


for i in range(int(input())):
	apartment = input()
	over = int(apartment[0]) - 1
	clicked = 10 * over
	clicked += sum(range(1, len(apartment) + 1))
	print(clicked)


t1 = int(input())
for i in range(t1):
	x = str(input())
	if len(x) < 4:
		p = int(x[-1]) - 1
		l = p * 10
		if len(x) == 1:
			l += 1
		if len(x) == 2:
			l += 3
		if len(x) == 3:
			l += 6
		print(l)
	else:
		p = int(x[-1])
		l = p * 10
		print(l)


def zip_sorted(a, b):
	(a, b) = zip(*sorted(zip(a, b)))
	sorted(zip(a, b), key=lambda x: x[1])
	return (a, b)
t = int(input())
for i in range(t):
	x = int(input())
	a = [1, 2, 3, 4, 5, 6, 7, 8, 9]
	sum1 = 0
	count1 = 0
	for t1 in a:
		for t2 in range(1, 5):
			b = str(t1) * t2
			if int(b) == x:
				count1 = 1
				sum1 = sum1 + t2
				break
			else:
				sum1 = sum1 + t2
		if count1 == 1:
			break
	print(sum1)


for _ in range(int(input())):
	s = input()
	length = len(s)
	num = int(s[0])
	add = 0
	if length == 1:
		add = 1
	elif length == 2:
		add = 3
	elif length == 3:
		add = 6
	else:
		add = 10
	print(10 * (num - 1) + add)


t = int(input())
for i in range(t):
	n = input()
	n1 = int(n)
	temp = (int(n[0]) - 1) * 10
	for i in range(len(n) + 1):
		temp = temp + i
	print(temp)


t = int(input())
for _ in range(t):
	x = int(input())
	digit = x % 10
	count = 0
	while x != 0:
		count += 1
		x //= 10
	add = 0
	for i in range(1, count + 1):
		add += i
	digit_sum = 0
	while digit != 0:
		digit -= 1
		if digit <= 0:
			break
		else:
			digit_sum += 10
	tot = digit_sum + add
	print(tot)


import sys
import bisect as bi
import collections as cc
import heapq as hp
input = sys.stdin.readline
I = lambda : list(map(int, input().split()))
ar = []
for i in range(1, 10):
	j = str(i)
	while int(j) <= 10000:
		ar.append(int(j))
		j += str(i)
for tc in range(int(input())):
	(n,) = I()
	x = ar.index(n)
	y = ar[:x + 1]
	print(len(''.join(map(str, y))))


a = []
for i in range(1, 10):
	for j in range(1, 5):
		a.append(str(i) * j)
t = int(input())
while t:
	x = str(input())
	ans = a.index(x)
	w = ''.join(a[:ans + 1])
	print(len(w))
	t = t - 1


numberOfCases = int(input())
for _ in range(numberOfCases):
	room = input()
	number = int(room[0])
	length = len(room)
	presses = 0
	if number > 1:
		presses = (number - 1) * 10
	presses += sum([x for x in range(1, length + 1)])
	print(presses)


t = int(input())
tmp = [1, 3, 6, 10]
for _ in range(t):
	x = input()
	a = list(str(x))
	print((int(a[0]) - 1) * 10 + tmp[len(a) - 1])


test_count = int(input())
tests = []
for _ in range(test_count):
	tests.append(input())
for test in tests:
	digit = int(test[0])
	length = len(test)
	print((digit - 1) * (1 + 2 + 3 + 4) + sum(range(1, length + 1)))


for __ in range(int(input())):
	n = int(input())
	ans = 0
	ans += (int(str(n)[0]) - 1) * 10
	x = len(str(n))
	ans += x * (x + 1) // 2
	print(ans)


t = int(input())
for i in range(t):
	r = 0
	d = 1
	x = int(input())
	r += (x % 10 - 1) * 10
	while x > 0:
		r += d
		d += 1
		x = x // 10
	print(r)


import os
import sys
from io import BytesIO, IOBase
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
input = lambda : sys.stdin.readline().rstrip('\r\n')

def RS():
	return input()

def RN():
	return int(input())

def RM():
	return map(int, input().split())

def RL():
	return list(map(int, input().split()))
for _ in range(RN()):
	n = RS()
	cnt = (int(n[0]) - 1) * 10
	cnt += len(n) * (len(n) + 1) // 2
	print(cnt)


t = int(input())
for _ in range(t):
	x = int(input())
	res = 0
	found = False
	for i in range(1, 10):
		if not found and i <= x:
			j = i
			for k in [1, 11, 111, 1111]:
				j = k * i
				res += len(str(k))
				if j == x:
					print(res)
					found = True


def solve():
	n = input().strip()
	(digit, l) = (int(n[0]), len(n))
	print(10 * (digit - 1) + l * (l + 1) // 2)
for _ in range(int(input())):
	solve()


def f(n):
	s = str(n)
	if len(s) < 2:
		return 1
	else:
		for i in range(1, len(s)):
			if s[i] != s[i - 1]:
				return 0
		else:
			return 1
a = [str(i) for i in range(1, 10000 + 1) if f(i)]
a.sort()
t = int(input())
for _ in range(t):
	inp = int(input())
	res = 0
	for i in range(a.index(str(inp)) + 1):
		res += len(str(a[i]))
	print(res)


t = int(input())
for test in range(t):
	x = int(input())
	temp = str(x)
	n = len(temp)
	answer = 10 * (x % 10 - 1) + n * (n + 1) // 2
	print(answer)


for _ in range(int(input())):
	n = int(input())
	a = n % 10
	b = 10 * (a - 1)
	x = str(n)
	if len(x) == 1:
		m = 1
	elif len(x) == 2:
		m = 3
	elif len(x) == 3:
		m = 6
	else:
		m = 10
	f = b + m
	print(f)


from sys import stdin, stdout
for _ in range(int(stdin.readline())):
	s = input()
	n = len(s)
	row = int(s[0])
	ans = 10 * (row - 1) + n * (n + 1) // 2
	print(ans)


t = int(input())
for j in range(t):
	s = input()
	count = 0
	n = int(s[0])
	count = (n - 1) * 10
	l = len(s)
	if l == 1:
		count += 1
	elif l == 2:
		count += 3
	elif l == 3:
		count += 6
	else:
		count += 10
	print(count)


t = int(input())
for _ in range(t):
	n = int(input())
	tot = 10 * ((n - 1) % 10)
	s = str(n)
	l = len(s)
	tot += l * (l + 1) // 2
	print(tot)


def dio(s):
	x = (int(s[0]) - 1) * 10 + sum([1, 2, 3, 4][:len(s)])
	return x
for _ in range(int(input())):
	print(dio(input()))


t = int(input())
for i in range(t):
	x = input()
	num = x[0]
	l = len(x)
	sol = (int(num) - 1) * 10 + l * (l + 1) // 2
	print(sol)


for _ in range(int(input())):
	x = int(input())
	a = x
	cnt = 0
	while a != 0:
		a = a // 10
		cnt += 1
	a = x % 10
	ans = (a - 1) * 10 + cnt * (cnt + 1) // 2
	print(ans)


def lenandno(n):
	p = len(str(n))
	digit = int(str(n)[0])
	return (p, digit)
t = int(input())
for i in range(t):
	n = int(input())
	(l, dig) = lenandno(n)
	lent = {1: 1, 2: 3, 3: 6, 4: 10}
	print(10 * (dig - 1) + lent[l])


t = int(input())
a = []
for i in range(t):
	total = 0
	count = 0
	n = str(input())
	count = int(n[0])
	int(n)
	total += sum(list(range(1, len(n) + 1))) + 10 * (count - 1)
	a.append(total)
for i in a:
	print(i)


import sys
import math
input = sys.stdin.readline

def inp():
	return int(input())

def inara():
	return list(map(int, input().split()))

def insr():
	s = input()
	return list(s[:len(s) - 1])

def invr():
	return map(int, input().split())
t = inp()
for _ in range(t):
	n = inp()
	ans = 0
	for i in range(1, 10):
		curr = i
		ans += 1
		digit = 1
		flag = curr == n
		while True:
			if flag:
				break
			if curr > 10000:
				ans -= digit
				break
			curr *= 10
			curr += i
			digit += 1
			ans += digit
			flag |= curr == n
		if flag:
			break
	print(ans)


t = eval(input())
for i in range(t):
	x = input()
	if len(x) == 1:
		print(10 * eval(x) - 9)
	elif len(x) == 2:
		print(10 * eval(x[0]) - 7)
	elif len(x) == 3:
		print(10 * eval(x[0]) - 4)
	elif len(x) == 4:
		print(10 * eval(x[0]))


def main():
	t = int(input())
	for i in range(t):
		x = int(input())
		v = 0
		for a in range(1, 10):
			for i in range(1, 5):
				s = str(a)
				s = s * i
				y = int(s)
				if y == x:
					for z in range(1, a):
						v += 10
					for w in range(i + 1):
						v += w
					break
				else:
					continue
		print(v)
main()


t = int(input())
for _ in range(t):
	x = int(input())
	a = x % 10
	ch = str(x)
	b = len(ch)
	s = 0
	t = 1
	k = 0
	while t < a:
		s += 10
		t += 1
	if t == a:
		if b == 1:
			s += 1
		elif b == 2:
			s += 3
		elif b == 3:
			s += 6
		elif b == 4:
			s += 10
	print(s)


t = int(input())
while t > 0:
	number_of_apartment = input()
	if len(number_of_apartment) == 1:
		count_of_toches = 10 * (int(number_of_apartment[0]) - 1) + 1
	elif len(number_of_apartment) == 2:
		count_of_toches = 10 * (int(number_of_apartment[0]) - 1) + 3
	elif len(number_of_apartment) == 3:
		count_of_toches = 10 * (int(number_of_apartment[0]) - 1) + 6
	else:
		count_of_toches = 10 * (int(number_of_apartment[0]) - 1) + 10
	print(count_of_toches)
	t -= 1


t = int(input())

def sum_rec(p):
	if p == 1:
		return 1
	else:
		return p + sum_rec(p - 1)
for i in range(t):
	a = int(input())
	r = a % 10
	p = len(str(a))
	print((r - 1) * 10 + sum_rec(p))


import sys
t = sys.stdin.readline()
for i in range(0, int(t)):
	end = str(sys.stdin.readline())
	sys.stdout.write(str(int(10 * int(end[0:1]) - 10 + len(end) * (len(end) - 1) / 2)) + '\n')


t = int(input())
while t:
	t -= 1
	x = input()
	d = int(x[0]) - 1
	res = len(x) * (len(x) + 1) // 2
	res += d * 10
	print(res)


t = int(input())
for i in range(t):
	w = int(input())
	c = str(w)
	a = len(c)
	g = w % 10
	j = (g - 1) * 10
	if a == 4:
		j = j + 10
	elif a == 3:
		j = j + 6
	elif a == 2:
		j = j + 3
	else:
		j = j + 1
	print(j)


t = int(input())
a = [1, 11, 111, 1111, 2, 22, 222, 2222, 3, 33, 333, 3333, 4, 44, 444, 4444, 5, 55, 555, 5555, 6, 66, 666, 6666, 7, 77, 777, 7777, 8, 88, 888, 8888, 9, 99, 999, 9999]
b = [1, 2, 3, 4, 1, 2, 3, 4, 1, 2, 3, 4, 1, 2, 3, 4, 1, 2, 3, 4, 1, 2, 3, 4, 1, 2, 3, 4, 1, 2, 3, 4, 1, 2, 3, 4]
for i in range(t):
	sum1 = 0
	x = int(input())
	l = a.index(x)
	for k in range(l + 1):
		sum1 = sum1 + b[k]
	print(sum1)


mod = 10 ** 9 + 7

def solve():
	x = int(input())
	ans = 0
	ok = False
	for i in range(1, 10):
		tmp = 0
		for j in range(4):
			tmp = tmp * 10 + i
			ans += j + 1
			if tmp == x:
				ok = True
				break
		if ok:
			break
	print(ans)
t = 1
t = int(input())
while t > 0:
	solve()
	t -= 1


t = int(input())
l = []
for i in range(1, 10):
	x = str(i)
	for j in range(1, 5):
		l.append(x * j)
while t:
	n = int(input())
	ans = 0
	for i in l:
		if int(i) == n:
			ans += len(i)
			break
		else:
			ans += len(i)
	print(ans)
	t -= 1


t = int(input())
for _ in range(t):
	n = input()
	count = 10 * (int(n[0]) - 1)
	ll = len(n)
	for i in range(1, ll + 1):
		count += i
	print(count)


buff = [1, 3, 6, 10]
for _ in range(int(input())):
	answered = input()
	n = len(answered)
	prev = int(answered[0]) - 1
	print(buff[n - 1] + prev * 10)


t = int(input())
while t:
	x = input()
	l = len(x)
	x = list(x)
	a = 0
	x = int(x[0])
	for i in range(x, 1, -1):
		a += 10
	for i in range(l, 1, -1):
		a += i
	print(a + 1)
	t -= 1


tc = int(input())
for _ in range(tc):
	N = str(input())
	result = 0
	result += (int(N[0]) - 1) * 10
	if len(N) == 1:
		result += 1
	elif len(N) == 2:
		result += 3
	elif len(N) == 3:
		result += 6
	else:
		result += 10
	print(result)


t = int(input())
for _ in range(t):
	n = int(input())
	counting = 0
	is_done = False
	for i in range(1, 10):
		for c in range(1, 5):
			curr_int = int(str(i) * c)
			counting += c
			if curr_int == n:
				print(counting)
				is_done = True
				break
		if is_done:
			break


def solve(n):
	a = 0
	for i in range(1, len(str(n)) + 1):
		a += i
	return (int(str(n)[0]) - 1) * 10 + a
t = int(input())
for tt in range(t):
	n = int(input())
	print(solve(n))


a = int(input())
for i in range(0, a):
	b = int(input())
	rem = b % 10
	nd = 0
	while b > 0:
		b = b // 10
		nd = nd + 1
	print(10 * (rem - 1) + nd * (nd + 1) // 2)


t = int(input())
while t > 0:
	t = t - 1
	x = int(input())
	a = list(str(x))
	if a[0] == '9':
		c = 0
		if len(a) == 4:
			print(90)
		elif len(a) == 3:
			print(86)
		elif len(a) == 2:
			print(83)
		else:
			print(81)
	elif a[0] == '8':
		c = 0
		if len(a) == 4:
			print(80)
		elif len(a) == 3:
			print(76)
		elif len(a) == 2:
			print(73)
		else:
			print(71)
	elif a[0] == '7':
		c = 0
		if len(a) == 4:
			print(70)
		elif len(a) == 3:
			print(66)
		elif len(a) == 2:
			print(63)
		else:
			print(61)
	elif a[0] == '6':
		c = 0
		if len(a) == 4:
			print(60)
		elif len(a) == 3:
			print(56)
		elif len(a) == 2:
			print(53)
		else:
			print(51)
	elif a[0] == '5':
		c = 0
		if len(a) == 4:
			print(50)
		elif len(a) == 3:
			print(46)
		elif len(a) == 2:
			print(43)
		else:
			print(41)
	elif a[0] == '4':
		c = 0
		if len(a) == 4:
			print(40)
		elif len(a) == 3:
			print(36)
		elif len(a) == 2:
			print(33)
		else:
			print(31)
	elif a[0] == '3':
		c = 0
		if len(a) == 4:
			print(30)
		elif len(a) == 3:
			print(26)
		elif len(a) == 2:
			print(23)
		else:
			print(21)
	elif a[0] == '2':
		c = 0
		if len(a) == 4:
			print(20)
		elif len(a) == 3:
			print(16)
		elif len(a) == 2:
			print(13)
		else:
			print(11)
	elif a[0] == '1':
		c = 0
		if len(a) == 4:
			print(10)
		elif len(a) == 3:
			print(6)
		elif len(a) == 2:
			print(3)
		else:
			print(1)


for i in range(int(input())):
	st = input()
	ind = int(st[0]) - 1
	answer = ind * 10
	if len(st) == 4:
		answer += 10
	if len(st) == 3:
		answer += 6
	if len(st) == 2:
		answer += 3
	if len(st) == 1:
		answer += 1
	print(answer)


t = int(input())
for _ in range(t):
	x = int(input())
	buttons_pressed = 0
	buttons_pressed += (x % 10 - 1) * 10
	x = str(x)
	buttons_pressed += int((len(x) + 1) * len(x) / 2)
	print(buttons_pressed)


from collections import Counter as cnt, defaultdict as dic
iin = lambda : int(input())
lin = lambda : list(map(int, input().rstrip().split()))
TEST_CASES = True

def main():
	n = iin()
	num = n % 10
	c = 0
	s = [1, 2, 3, 4]
	while n:
		c += 1
		n = n // 10
	print((num - 1) * 10 + sum(s[:c]))
if not TEST_CASES:
	main()
else:
	[main() for _ in range(int(input()))]


import sys
reader = (s.rstrip() for s in sys.stdin)
input = reader.__next__

def gift():
	for _ in range(t):
		num = input()
		tsnum = int(num[0])
		lenNum = len(num)
		yield ((tsnum - 1) * 10 + lenNum * (lenNum + 1) // 2)
t = int(input())
ans = gift()
print(*ans, sep='\n')


t = int(input())
for _ in range(t):
	z = input()
	k = len(z)
	t = int(z[0])
	print((t - 1) * 10 + sum([i + 1 for i in range(k)]))


for _ in range(int(input())):
	x = input()
	dig = int(x[0])
	num_of_dig = len(x)
	if num_of_dig % 4 == 0:
		print(10 * dig)
	else:
		mod = num_of_dig % 4
		print(10 * (dig - 1) + mod * (mod + 1) // 2)


t = int(input())
while t > 0:
	n = int(input())
	a = n % 10 - 1
	cou = 0
	while n > 0:
		cou += 1
		n //= 10
	ans = a * 10 + cou * (cou + 1) // 2
	print(ans)
	t = t - 1


tc = int(input())
for t in range(tc):
	x = input()
	c = len(x)
	d = int(x[0])
	print((d - 1) * 10 + c * (c + 1) // 2)


s = eval(input())
ls1 = []
z = 0
for i in range(s):
	z = input()
	ls1.append(z)

def caculate(x):
	first_str = eval(x[0])
	length = len(x)
	t = 0
	for i in range(1, length + 1):
		t += i
	char = int((first_str - 1) * 10 + t)
	return char
for j in ls1:
	print(caculate(j))


for i in range(int(input())):
	n = int(input())
	ans = (int(str(n)[0]) - 1) * 10
	for j in range(1, len(str(n)) + 1):
		ans += j
	print(ans)


def calculate(number, __x):
	answ = (number - 1) * 10
	for i in range(len(__x)):
		answ += i + 1
	return answ
test = int(input())
for i in range(test):
	__x = input()
	apartment = int(__x)
	number = int(__x[0])
	print(calculate(number, __x))


T = int(input())
for _ in range(T):
	n = int(input())
	s = str(n)
	l = len(s)
	i = int(s[0])
	ans = 10 * (i - 1) + l * (l + 1) / 2
	print(int(ans))


t = int(input())
while t > 0:
	x = int(input())
	ct = 0
	n = x % 10
	while x > 0:
		ct += 1
		x //= 10
	ans = (n - 1) * 10 + ct * (ct + 1) // 2
	print(ans)
	t -= 1


for _ in range(int(input())):
	n = input()
	k = int(n[0]) - 1
	l = len(n)
	baal = k * 10 + l * (l + 1) // 2
	print(baal)


t = int(input())
for _ in range(t):
	x = input()
	a = x[0]
	a = int(a)
	ans = 0
	ans += 10 * (a - 1)
	i = len(x)
	while i >= 0:
		ans += i
		i -= 1
	print(ans)


s = [1, 2, 3, 4]
for i in range(int(input())):
	x = int(input())
	x1 = x % 10
	d = (x1 - 1) * sum(s)
	f = len(str(x))
	print(d + sum(s[0:f]))


f = input()
t = 0
while t < int(f):
	boring = input()
	l = len(boring)
	c = int(boring[0])
	if l == 1:
		d = 1
	elif l == 2:
		d = 3
	elif l == 3:
		d = 6
	elif l == 4:
		d = 10
	print(d + (c - 1) * 10)
	t += 1


def apartment(a):
	first = int(str(a)[0])
	n = len(a)
	return 10 * (first - 1) + n * (n + 1) // 2
t = int(input())
for _ in range(t):
	a = input()
	res = apartment(a)
	print(res)


import math
n = int(input())
for i in range(n):
	a = int(input())
	print((int(str(a)[0]) - 1) * 10 + sum(range(10)[1:len(str(a)) + 1]))


from sys import stdin, stdout
n = int(stdin.readline())
for i in range(n):
	a = int(stdin.readline())
	t = a
	digits = 0
	while t != 0:
		t = t // 10
		digits += 1
	count = 0
	counter = 0
	for i in range(1, 10):
		if counter == 1:
			break
		for j in range(1, 5):
			if i < a % 10 or (i == a % 10 and int(str(i) * j) <= a):
				count += j
			else:
				counter = 1
				break
	print(count)


from sys import stdin, stdout

def NOD(n):
	cnt = 0
	while n:
		cnt = cnt + 1
		n = int(n / 10)
	return cnt

def preprocess():
	arr = []
	for i in range(1, 10):
		num = i
		while num <= 9999:
			arr.append(num)
			num = num * 10 + i
	return arr

def main():
	R = stdin.readline
	W = stdout.write
	arr = preprocess()
	tc = int(R())
	for cs in range(tc):
		n = int(R())
		ans = 0
		for k in arr:
			ans += NOD(k)
			if k == n:
				break
		W(str(ans))
		W(str('\n'))
main()


print('\n'.join([(lambda s: '{}'.format(10 * (int(s[0]) - 1) + len(s) * (len(s) + 1) // 2))(input()) for i in range(int(input()))]))


box = []
for i in range(1, 10):
	temp = ''
	for j in range(4):
		temp += str(i)
		box.append(int(temp))
dp = [0] * len(box)
for i in range(len(box)):
	if i == 0:
		dp[i] = 1
	else:
		dp[i] = dp[i - 1] + len(str(box[i]))
t = int(input())
for _ in range(t):
	x = int(input())
	print(dp[box.index(x)])


t = int(input())
for i in range(t):
	p = 0
	x = int(input())
	p = (x % 10 - 1) * 10
	for j in range(1, len(str(x)) + 1):
		p = p + j
	print(p)


case = int(input())
for i in range(case):
	x = input().strip('\n\r')
	y = int(x[0])
	z = len(x)
	print((y - 1) * 10 + z * (z + 1) // 2)


def sol(x):
	c = 0
	for i in range(1, 10):
		for j in range(1, 5):
			c += j
			if str(i) * j == x:
				return c
for _ in range(int(input())):
	print(sol(input()))


t = int(input())
for i in range(t):
	x = int(input())
	n = x % 10
	v = len(str(x))
	v = v * (v + 1) // 2
	ans = (n - 1) * 10 + v
	print(ans)


def sum(x):
	a = 0
	for i in range(1, x + 1):
		a += i
	return a
for _ in range(int(input())):
	x = input()
	length = len(x)
	for i in range(1, 10):
		if i == int(x[0]):
			print(10 * (i - 1) + sum(length))


d = {1: 1, 2: 3, 3: 6, 4: 10}
for i in range(int(input())):
	num = input()
	print((int(num[0]) - 1) * 10 + d[len(num)])


import sys
import os
from io import BytesIO, IOBase
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
input = lambda : sys.stdin.readline().rstrip('\r\n')
import math
import random
import re
import heapq
t = int(input())
while t:
	t -= 1
	n = int(input())
	muls = [1, 11, 111, 1111]
	kp = 0
	answered = False
	for i in range(1, 10):
		for m in range(4):
			kp += m + 1
			if muls[m] * i == n:
				answered = True
				break
		if answered:
			break
	print(kp)


for _ in range(int(input())):
	n = input().strip()
	s = int(n)
	c = (int(n[0]) - 1) * 10
	d = 1
	if 1:
		for i in range(len(n)):
			c += d
			d += 1
	print(c)


for _ in range(int(input())):
	n = int(input())
	l = len(str(n))
	num = int(str(n)[:1]) - 1
	num = num * 10
	if l == 4:
		num += 10
	elif l == 3:
		num += 6
	elif l == 2:
		num += 3
	else:
		num += 1
	print(num)


t = int(input())
for _ in range(t):
	n = input()
	digit = int(n[0])
	initial_ans = (digit - 1) * 10
	rem = 0
	for i in range(1, len(n) + 1):
		rem += i
	print(initial_ans + rem)


cases = int(input())
for t in range(cases):
	x = int(input())
	y = x % 10
	s = 10 * (y - 1)
	v = len(str(x))
	s += v * (v + 1) // 2
	print(s)


for i in range(int(input())):
	a = input()
	n = 10
	x = int(a[0])
	y = int(len(a))
	t = (x - 1) * 10 + y * (y + 1) / 2
	print(int(t))


testcases = int(input())
while testcases:
	val = int(input())
	length = len(str(val))
	digit = val % 10
	sumval = (digit - 1) * 10
	if length == 1:
		sumval += 1
	elif length == 2:
		sumval += 3
	elif length == 3:
		sumval += 6
	else:
		sumval += 10
	print(sumval)
	testcases -= 1


t = int(input())
for i in range(t):
	n = input()
	print((int(n[0]) - 1) * 10 + sum(list(range(0, len(n) + 1))))


a = int(input())
for i in range(0, a):
	b = int(input())
	c = str(b)
	d = len(c)
	e = 0
	if d == 1:
		e = e + (b - 1) * 10 + 1
	elif d == 2:
		e = e + (b // 11 - 1) * 10 + 3
	elif d == 3:
		e = e + (b // 111 - 1) * 10 + 6
	elif d == 4:
		e = e + (b // 1111 - 1) * 10 + 10
	print(e)


tests = int(input())
for t in range(tests):
	n = input()
	digit = int(n[0])
	print(int((digit - 1) * 10 + (len(n) + 1) * len(n) / 2))


import sys
T = int(sys.stdin.readline())
for _ in range(T):
	x = sys.stdin.readline().strip()
	print((int(x) % 10 - 1) * 10 + len(x) * (len(x) + 1) // 2)


import os
import sys
import math
from io import BytesIO, IOBase
from fractions import Fraction
import collections
from itertools import permutations
from collections import defaultdict
from collections import deque
import threading
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
input = lambda : sys.stdin.readline().rstrip('\r\n')

class Factorial:

	def __init__(self, MOD):
		self.MOD = MOD
		self.factorials = [1, 1]
		self.invModulos = [0, 1]
		self.invFactorial_ = [1, 1]

	def calc(self, n):
		if n <= -1:
			print('Invalid argument to calculate n!')
			print('n must be non-negative value. But the argument was ' + str(n))
			exit()
		if n < len(self.factorials):
			return self.factorials[n]
		nextArr = [0] * (n + 1 - len(self.factorials))
		initialI = len(self.factorials)
		prev = self.factorials[-1]
		m = self.MOD
		for i in range(initialI, n + 1):
			prev = nextArr[i - initialI] = prev * i % m
		self.factorials += nextArr
		return self.factorials[n]

	def inv(self, n):
		if n <= -1:
			print('Invalid argument to calculate n^(-1)')
			print('n must be non-negative value. But the argument was ' + str(n))
			exit()
		p = self.MOD
		pi = n % p
		if pi < len(self.invModulos):
			return self.invModulos[pi]
		nextArr = [0] * (n + 1 - len(self.invModulos))
		initialI = len(self.invModulos)
		for i in range(initialI, min(p, n + 1)):
			next = -self.invModulos[p % i] * (p // i) % p
			self.invModulos.append(next)
		return self.invModulos[pi]

	def invFactorial(self, n):
		if n <= -1:
			print('Invalid argument to calculate (n^(-1))!')
			print('n must be non-negative value. But the argument was ' + str(n))
			exit()
		if n < len(self.invFactorial_):
			return self.invFactorial_[n]
		self.inv(n)
		nextArr = [0] * (n + 1 - len(self.invFactorial_))
		initialI = len(self.invFactorial_)
		prev = self.invFactorial_[-1]
		p = self.MOD
		for i in range(initialI, n + 1):
			prev = nextArr[i - initialI] = prev * self.invModulos[i % p] % p
		self.invFactorial_ += nextArr
		return self.invFactorial_[n]

class Combination:

	def __init__(self, MOD):
		self.MOD = MOD
		self.factorial = Factorial(MOD)

	def ncr(self, n, k):
		if k < 0 or n < k:
			return 0
		k = min(k, n - k)
		f = self.factorial
		return f.calc(n) * f.invFactorial(max(n - k, k)) * f.invFactorial(min(k, n - k)) % self.MOD
for _ in range(int(input())):
	n = input()
	l = len(n)
	r = (int(n[0]) - 1) * 10 + l * (l + 1) // 2
	print(r)


tsts = int(input())
for i in range(tsts):
	num = input()
	nth = int(num[0])
	dld = 10 * (nth - 1)
	if len(num) == 1:
		dld += 1
	elif len(num) == 2:
		dld += 3
	elif len(num) == 3:
		dld += 6
	elif len(num) == 4:
		dld += 10
	print(dld)


from sys import stdin
for i in range(int(stdin.readline())):
	n = int(stdin.readline())
	d = n % 10
	sum = (d - 1) * 10
	k = len(str(n))
	sum = sum + k * (k + 1) // 2
	print(sum)


for t in range(int(input())):
	n = int(input())
	stn = str(n)
	ln = len(stn)
	temp = 0
	if ln == 1:
		temp = 1
	if ln == 2:
		temp = 3
	if ln == 3:
		temp = 6
	if ln == 4:
		temp = 10
	print((int(stn[0]) - 1) * 10 + temp)


import sys
INP = lambda : sys.stdin.readline().strip()
INT = lambda : int(INP())
MAP = lambda : map(int, INP().split())
ARR = lambda : [int(i) for i in INP().split()]

def JOIN(arr, x=' '):
	return x.join([str(i) for i in arr])

def EXIT(x='NO'):
	print(x)
	exit()
for _ in range(INT()):
	s = INP()
	x = [1, 3, 6, 10]
	print((int(s[0]) - 1) * 10 + x[len(s) - 1])


n = int(input())
for _ in range(n):
	num = input()
	res = 0
	for i in range(1, len(num) + 1):
		res += i
	res += (int(num[0]) - 1) * 10
	print(res)


T = int(input())
l = ['1', '11', '111', '1111', '2', '22', '222', '2222', '3', '33', '333', '3333', '4', '44', '444', '4444', '5', '55', '555', '5555', '6', '66', '666', '6666', '7', '77', '777', '7777', '8', '88', '888', '8888', '9', '99', '999', '9999']
while T:
	ans = 0
	N = input()
	for j in range(len(l)):
		if l[j] == N:
			ans += len(N)
			break
		else:
			ans += len(l[j])
	print(ans)
	T = T - 1


(z, zz) = (input, lambda : list(map(int, z().split())))
fast = lambda : stdin.readline().strip()
zzz = lambda : [int(i) for i in fast().split()]
(szz, graph, mod, szzz) = (lambda : sorted(zz()), {}, 10 ** 9 + 7, lambda : sorted(zzz()))
from string import *
from re import *
from collections import *
from queue import *
from sys import *
from collections import *
from math import *
from heapq import *
from itertools import *
from bisect import *
from collections import Counter as cc
from math import factorial as f
from bisect import bisect as bs
from bisect import bisect_left as bsl
from itertools import accumulate as ac

def lcd(xnum1, xnum2):
	return xnum1 * xnum2 // gcd(xnum1, xnum2)

def prime(x):
	p = ceil(x ** 0.5) + 1
	for i in range(2, p):
		if x % i == 0 and x != 2 or x == 0:
			return 0
	return 1

def dfs(u, visit, graph):
	visit[u] = 1
	for i in graph[u]:
		if not visit[i]:
			dfs(i, visit, graph)
num = 1
num = int(z())
arr = ['1', '11', '111', '1111', '2', '22', '222', '2222', '3', '33', '333', '3333', '4', '44', '444', '4444', '5', '55', '555', '5555', '6', '66', '666', '6666', '7', '77', '777', '7777', '8', '88', '888', '8888', '9', '99', '999', '9999']
for _ in range(num):
	n = z()
	ans = [0, 1, 3, 6, 10]
	t = bs(arr, n)
	print(t // 4 * 10 + ans[t % 4])


a = input()
for x in range(int(a)):
	b = input()
	list1 = [1, 3, 6, 10]
	ans = 0
	ans += (int(b[0]) - 1) * 10
	ans += list1[len(b) - 1]
	print(ans)


def mi():
	return map(int, input().split())
for _ in range(int(input())):
	x = int(input())
	z = x % 10
	k = len(str(x))
	out = 10 * (z - 1)
	arr = [1, 2, 3, 4]
	out += sum(arr[:k])
	print(out)


t = int(input())
semi = [1, 2, 3, 4]
for i in range(t):
	ans = 0
	n = str(input())
	x = int(n[0])
	le = len(n)
	if x > 1:
		ans = (x - 1) * (1 + 2 + 3 + 4)
	for j in range(le):
		ans = ans + semi[j]
	print(ans)


t = int(input())
for q in range(t):
	x = int(input())
	s = str(x)
	cnt = 0
	for i in s:
		if s.count(i) != 0:
			cnt = int(i)
	ans = 0
	for i in range(1, cnt):
		ans += 10
	if s.count(str(cnt)) == 1:
		ans += 1
	elif s.count(str(cnt)) == 2:
		ans += 3
	elif s.count(str(cnt)) == 3:
		ans += 6
	else:
		ans += 10
	print(ans)


t = int(input())
res = []
for _ in range(t):
	x = input()
	count = 10 * (int(x[0]) - 1)
	n = len(x)
	count += (1 + n) * n / 2
	res.append(count)
for r in res:
	print(int(r))


t = int(input())
for _ in range(t):
	n = input()
	sum = (int(n[0]) - 1) * 10
	v = len(n)
	sum += v * (v + 1) // 2
	print(sum)


test_cases = int(input())
res = []
for i in range(0, test_cases):
	dialed_number = int(input())
	count = 0
	for j in range(1, 10):
		number = j
		breaks = False
		count = count + 1
		if number == dialed_number:
			res.append(count)
			break
		for k in range(2, 5):
			number = number * 10 + j
			count = count + k
			if number == dialed_number:
				res.append(count)
				break
for i in res:
	print(i)


for _ in range(int(input())):
	s = input()
	arr = [1, 3, 6, 10]
	ans = arr[len(s) - 1]
	if s[0] == '1':
		print(ans)
	else:
		ans += 10 * (int(s[0]) - 1)
		print(ans)


for i in range(int(input())):
	n = int(input())
	a = [0] * 5
	a[0] = 1
	a[1] = 3
	a[2] = 6
	a[3] = 10
	l = len(str(n))
	c = n % 10
	print(10 * (c - 1) + a[l - 1])


import math
for nt in range(int(input())):
	n = int(input())
	k = n % 10
	ans = 10 * (k - 1)
	r = len(str(n))
	if r == 1:
		ans += 1
	elif r == 2:
		ans += 3
	elif r == 3:
		ans += 6
	else:
		ans += 10
	print(ans)


n = int(input())
for i in range(n):
	m = input()
	k = len(m)
	p = int(m[0])
	ans = (p - 1) * 10 + k * (k + 1) // 2
	print(ans)


import sys
inp = sys.stdin.buffer.readline
inar = lambda : list(map(int, inp().split()))
inin = lambda : int(inp())
inst = lambda : inp().decode().strip()
wrt = sys.stdout.write
pr = lambda *args, end='\n': wrt(' '.join([str(x) for x in args]) + end)
enum = enumerate
inf = float('inf')
cdiv = lambda x, y: -(-x // y)
mod = 1000000007
_T_ = inin()
for _t_ in range(_T_):
	s = inst()
	ans = 0
	ans += (int(s[0]) - 1) * 10
	ans += len(s) * (len(s) + 1) // 2
	print(ans)


from sys import stdin
t = int(stdin.readline())
for i in range(t):
	x = int(stdin.readline())
	n = int(str(x)[0])
	total = 0
	for i in range(1, n):
		total += 10
	for i in range(1, len(str(x)) + 1):
		total += i
	print(total)


t = int(input())
while t > 0:
	t -= 1
	n = input().strip()
	nn = int(n[0])
	a = (nn - 1) * 10
	s = 1
	for i in n:
		a += s
		s += 1
	print(a)


import sys
t = int(input())
while t > 0:
	t -= 1
	n = input()
	first = int(n[0], 10)
	ans = 10 * (first - 1) + len(n) * (len(n) + 1) / 2
	print(int(ans))


times = int(input())
for i in range(0, times):
	k = input()
	count = 0
	for j in range(int(k[0]) - 1, 0, -1):
		count += 10
	for j in range(0, len(k) + 1):
		count += j
	print(str(count))


import sys
from functools import lru_cache, cmp_to_key
from heapq import merge, heapify, heappop, heappush, nsmallest
from math import ceil, floor, gcd, fabs, factorial, fmod, sqrt, inf, log
from collections import defaultdict as dd, deque, Counter as C
from itertools import combinations as comb, permutations as perm
from bisect import bisect_left as bl, bisect_right as br, bisect
from time import perf_counter
from fractions import Fraction
from decimal import Decimal
mod = pow(10, 9) + 7
mod2 = 998244353

def data():
	return sys.stdin.readline().strip()

def out(var, end='\n'):
	sys.stdout.write(str(var) + end)

def outa(*var, end='\n'):
	sys.stdout.write(' '.join(map(str, var)) + end)

def l():
	return list(sp())

def sl():
	return list(ssp())

def sp():
	return map(int, data().split())

def ssp():
	return map(str, data().split())

def l1d(n, val=0):
	return [val for i in range(n)]

def l2d(n, m, val=0):
	return [l1d(n, val) for j in range(m)]

def nat(number):
	return number * (number + 1) // 2
for _ in range(int(data())):
	x = data()
	answer = (int(x[0]) - 1) * 10
	answer += nat(len(x))
	out(answer)


import sys
t = int(input())
for _ in range(t):
	line = input()
	d = int(line[0]) * 10
	l = 4
	while l > len(line):
		d -= l
		l -= 1
	print(d)


def count(n):
	count = 0
	while n != 0:
		n //= 10
		count += 1
	return count
for _ in range(int(input())):
	a = int(input())
	ar = [1, 11, 111, 1111, 2, 22, 222, 2222, 3, 33, 333, 3333, 4, 44, 444, 4444, 5, 55, 555, 5555, 6, 66, 666, 6666, 7, 77, 777, 7777, 8, 88, 888, 8888, 9, 99, 999, 9999]
	ans = 0
	for i in ar:
		ans += count(i)
		if i == a:
			break
	print(ans)


for i in range(int(input())):
	n = int(input())
	if n == 1:
		print(1)
	elif n == 9999:
		print(90)
	elif n == 10000:
		print(95)
	elif len(str(n)) == 1:
		print(10 * (int(str(n)[0]) - 1) + 1)
	elif len(str(n)) == 2:
		print(10 * (int(str(n)[0]) - 1) + 3)
	elif len(str(n)) == 3:
		print(10 * (int(str(n)[0]) - 1) + 6)
	else:
		print(10 * (int(str(n)[0]) - 1) + 10)


tc = int(input())
for k in range(tc):
	line = input()
	first = int(line[0])
	N = len(line)
	total = 0
	s = 1 + 2 + 3 + 4
	total += s * (first - 1)
	for i in range(1, N + 1):
		total += i
	print(total)


for _ in range(int(input())):
	l = list(input())
	n = len(l)
	r = 0
	if n == 1:
		r = 1
	elif n == 2:
		r = 3
	elif n == 3:
		r = 6
	else:
		r = 10
	k = int(l[0])
	k -= 1
	print(k * 10 + r)


for _ in range(int(input())):
	a = input()
	x = int(a)
	sums = (x % 10 - 1) * 10
	if len(a) == 1:
		sums += 1
	elif len(a) == 2:
		sums += 3
	elif len(a) == 3:
		sums += 6
	else:
		sums += 10
	print(sums)


for o in range(int(input())):
	s = list(input())
	n = len(s)
	print((int(s[0]) - 1) * 10 + int(n * (n + 1) / 2))


from math import gcd
from bisect import bisect_left, bisect_right
from itertools import combinations
from itertools import permutations
from bisect import bisect_left
from math import ceil
from math import radians
from heapq import heapify, heappush, heappop, nsmallest
import bisect
from math import pi
from collections import deque
from math import factorial
from math import log, ceil
from collections import defaultdict
from math import *
from sys import stdin, stdout
import itertools
import os
import sys
import threading
from collections import deque, Counter, OrderedDict, defaultdict
from heapq import *
from fractions import Fraction
mod = int(pow(10, 9) + 7)

def ii():
	return int(input())

def si():
	return str(input())

def mi():
	return map(int, input().split())

def li1():
	return list(mi())

def fii():
	return int(stdin.readline())

def fsi():
	return str(stdin.readline())

def fmi():
	return map(int, stdin.readline().split())

def fli():
	return list(fmi())
abd = {'a': 0, 'b': 1, 'c': 2, 'd': 3, 'e': 4, 'f': 5, 'g': 6, 'h': 7, 'i': 8, 'j': 9, 'k': 10, 'l': 11, 'm': 12, 'n': 13, 'o': 14, 'p': 15, 'q': 16, 'r': 17, 's': 18, 't': 19, 'u': 20, 'v': 21, 'w': 22, 'x': 23, 'y': 24, 'z': 25}

def getKey(item):
	return item[0]

def sort2(l):
	return sorted(l, key=getKey)

def d2(n, m, num):
	return [[num for x in range(m)] for y in range(n)]

def isPowerOfTwo(x):
	return x and (not x & x - 1)

def decimalToBinary(n):
	return bin(n).replace('0b', '')

def ntl(n):
	return [int(i) for i in str(n)]

def powerMod(x, y, p):
	res = 1
	x %= p
	while y > 0:
		if y & 1:
			res = res * x % p
		y = y >> 1
		x = x * x % p
	return res
graph = defaultdict(list)
visited = [0] * 1000000
col = [-1] * 1000000

def bfs(d, v):
	q = []
	q.append(v)
	visited[v] = 1
	while len(q) != 0:
		x = q[0]
		q.pop(0)
		for i in d[x]:
			if visited[i] != 1:
				visited[i] = 1
				q.append(i)
		print(x)

def make_graph(e):
	d = {}
	for i in range(e):
		(x, y) = mi()
		if x not in d:
			d[x] = [y]
		else:
			d[x].append(y)
		if y not in d:
			d[y] = [x]
		else:
			d[y].append(x)
	return d

def gr2(n):
	d = defaultdict(list)
	for i in range(n):
		(x, y) = mi()
		d[x].append(y)
	return d

def connected_components(graph):
	seen = set()

	def dfs(v):
		vs = set([v])
		component = []
		while vs:
			v = vs.pop()
			seen.add(v)
			vs |= set(graph[v]) - seen
			component.append(v)
		return component
	ans = []
	for v in graph:
		if v not in seen:
			d = dfs(v)
			ans.append(d)
	return ans

def primeFactors(n):
	s = set()
	while n % 2 == 0:
		s.add(2)
		n = n // 2
	for i in range(3, int(sqrt(n)) + 1, 2):
		while n % i == 0 and i % 2 == 1:
			s.add(i)
			n = n // i
	if n > 2 and n % 2 == 1:
		s.add(n)
	return s

def find_all(a_str, sub):
	start = 0
	while True:
		start = a_str.find(sub, start)
		if start == -1:
			return
		yield start
		start += len(sub)

def SieveOfEratosthenes(n, isPrime):
	isPrime[0] = isPrime[1] = False
	for i in range(2, n):
		isPrime[i] = True
	p = 2
	while p * p <= n:
		if isPrime[p] == True:
			i = p * p
			while i <= n:
				isPrime[i] = False
				i += p
		p += 1
	return isPrime

def dijkstra(edges, f, t):
	g = defaultdict(list)
	for (l, r, c) in edges:
		g[l].append((c, r))
	(q, seen, mins) = ([(0, f, ())], set(), {f: 0})
	while q:
		(cost, v1, path) = heappop(q)
		if v1 not in seen:
			seen.add(v1)
			path = (v1, path)
			if v1 == t:
				return (cost, path)
			for (c, v2) in g.get(v1, ()):
				if v2 in seen:
					continue
				prev = mins.get(v2, None)
				next = cost + c
				if prev is None or next < prev:
					mins[v2] = next
					heappush(q, (next, v2, path))
	return float('inf')

def binsearch(a, l, r, x):
	while l <= r:
		mid = l + (r - 1) // 2
		if a[mid]:
			return mid
		elif a[mid] > x:
			l = mid - 1
		else:
			r = mid + 1
	return -1

def readTree(n):
	adj = [set() for _ in range(n)]
	for _ in range(n - 1):
		(u, v) = map(int, input().split())
		adj[u - 1].add(v - 1)
		adj[v - 1].add(u - 1)
	return adj

def treeOrderByDepth(n, adj, root=0):
	parent = [-2] + [-1] * (n - 1)
	ordered = []
	q = deque()
	q.append(root)
	depth = [0] * n
	while q:
		c = q.popleft()
		ordered.append(c)
		for a in adj[c]:
			if parent[a] == -1:
				parent[a] = c
				depth[a] = depth[c] + 1
				q.append(a)
	return (ordered, parent, depth)

def isSubSequence(str1, str2):
	m = len(str1)
	n = len(str2)
	j = 0
	i = 0
	while j < m and i < n:
		if str1[j] == str2[i]:
			j = j + 1
		i = i + 1
	return j == m

def nextPowerOf2(n):
	count = 0
	if n and (not n & n - 1):
		return n
	while n != 0:
		n >>= 1
		count += 1
	return 1 << count

def cou(n):
	c = 0
	while n > 1:
		c += 1
		n //= 2
	return c

def sortsec(l):
	return sorted(l, key=lambda x: x[1])

def BinarySearch(a, x):
	i = bisect_left(a, x)
	if i:
		return i - 1
	else:
		return -1

def subarray(A):
	r = set()
	p = {0}
	for x in A:
		p = {x | y for y in p} | {x}
		r |= p
	return len(r)

def setBitNumber(n):
	n |= n >> 1
	n |= n >> 2
	n |= n >> 4
	n |= n >> 8
	n |= n >> 16
	n = n + 1
	return n >> 1

def countSetBits(n):
	count = 0
	while n:
		count += n & 1
		n >>= 1
	return count

def allsub(l):
	n = len(l)
	a = []
	for i in range(n - 1):
		for j in range(i + 1, n):
			a.append(l[i:j])
	return a
for _ in range(ii()):
	n = ii()
	a = n % 10
	b = 0
	while n != 0:
		n = n // 10
		b += 1
	c = (a - 1) * 10
	print(c + b * (b + 1) // 2)


x = ''
t = int(input())
while t > 0:
	x = input()
	ans = int(len(x) * (len(x) + 1) / 2) + 10 * (int(x[0]) - 1)
	print(ans)
	t -= 1


import math
import sys
from collections import OrderedDict

class Graph:

	def __init__(self, Nodes, is_directed=False):
		self.nodes = Nodes
		self.adj_list = {}
		self.is_directed = is_directed
		for node in self.nodes:
			self.adj_list[node] = []

	def add_edge(self, u, v):
		self.adj_list[u].append(v)
		if self.is_directed == False:
			self.adj_list[v].append(u)

	def print_graph(self):
		for node in self.nodes:
			print(node, '->', self.adj_list[node])

	def degree_node(self, node):
		return len(self.adj_list[node])

	def dfsUTIL(self, v, visited, parents=[]):
		visited[v] = True
		for i in self.adj_list[v]:
			if visited[i] == False:
				self.dfsUTIL(i, visited, parents)
				parents.append(i)

	def dfs(self, v):
		visited = [False] * (max(self.adj_list) + 1)
		parents = [v]
		self.dfsUTIL(v, visited, parents)
		return parents

def dict_sort(ans):
	ans = sorted(ans.items(), reverse=True, key=lambda kv: kv[1])

def is_prime(n):
	if n == 1:
		return 0
	for i in range(2, int(math.sqrt(n)) + 1):
		if n % i == 0:
			return False
	return True

def swap(a, b):
	temp = a
	a = b
	b = temp
	return (a, b)

def seive_primes(n):
	flag = [0] * (n + 10)
	flag[1] = flag[0] = 1
	i = 2
	while i * i <= n + 1:
		if flag[i] == 0:
			j = i * i
			while j <= n + 1:
				flag[j] = 1
				j += i
		i += 1
	return flag

def factors(n):
	d = {}
	while n % 2 == 0:
		if 2 in d:
			d[2] += 1
		else:
			d[2] = 1
		n /= 2
	for i in range(3, int(n ** 0.5) + 1, 2):
		while n % i == 0:
			if i in d:
				d[i] += 1
			else:
				d[i] = 1
			n /= i
	n = int(n)
	if n > 1:
		d[n] = 1
	return d

def gcd(a, b):
	if b == 0:
		return a
	return gcd(b, a % b)

def lcm(a, b):
	return a * b // gcd(a, b)

def alphabates():
	return 'abcdefghijklmnopqrstuvwxyz'

def binary_search(ls, n, flag):
	low = 0
	hi = n - 1
	while low <= hi:
		mid = (low + hi) // 2
		if ls[mid] == flag:
			return mid
		elif ls[mid] > flag:
			hi = mid - 1
		else:
			low = mid + 1
	return -1

def qdrt(a, b, c):
	chk = b * b - 4 * a * c
	if chk >= 0:
		ans1 = (-b + chk ** 0.5) / (2 * a)
		ans2 = (-b - chk ** 0.5) / (2 * a)
		return [int(ans1), int(ans2)]
	return -1

def permutation(n, r):
	if n < r:
		return 0
	ans = 1
	for i in range(n - r + 1, n + 1):
		ans *= i
	return ans

def combination(n, r):
	if n < r:
		return 0
	ans = 1
	for i in range(r):
		ans *= n - i
	div = 1
	for i in range(2, r + 1):
		div *= i
	return ans // div

def ispow2(n):
	ans = int(math.log(n, 2))
	if 2 ** ans == n:
		return True
	return False

def _2dmat(n):
	flag = [[i + 1 for i in range(n)]]
	for i in range(2, n + 1):
		new = []
		for j in range((i - 1) * n + 1, i * n + 1):
			new.append(j)
		flag.append(new)
	return flag

def sumn(n):
	return n * (n + 1) // 2

def arrinp():
	ls = list(map(int, input().split()))
	return ls

def mult_inp():
	return map(float, input().split())

def main():
	n = input()
	lst = int(n[0]) - 1
	ans = sumn(4)
	ans = ans * lst + sumn(len(n))
	print(ans)
for _ in range(int(input())):
	main()


def read_int():
	return int(input())

def read_ints():
	return map(int, input().split(' '))
t = read_int()
for case_num in range(t):
	x = read_int()
	i = x % 10
	n = len(str(x))
	print(10 * (i - 1) + (1 + n) * n // 2)


t = int(input())
for i in range(t):
	x = input()
	d = int(x[0])
	l = len(x)
	r = (d - 1) * 10 + l * (l + 1) / 2
	print(int(r))


limit = int(input())
mainlst = []
for i in range(0, limit):
	num = int(input())
	mainlst.append(num)
for k in mainlst:
	s = 0
	i = 1
	lst = []
	for i in range(1, 10):
		for j in range(1, 5):
			s = s * 10 + i
			lst.append(s)
		s = 0
	i = lst.index(k)
	newlst = lst[0:i + 1]
	sum = 0
	for i in newlst:
		if i > 0 and i < 10:
			value = 1
		elif i > 10 and i < 100:
			value = 2
		elif i > 100 and i < 1000:
			value = 3
		elif i > 1000 and i < 10000:
			value = 4
		sum = sum + value
	print(sum)


import os
import sys
from io import BytesIO, IOBase
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
input = lambda : sys.stdin.readline().rstrip('\r\n')
import math
import bisect
from collections import Counter
import bisect
import heapq as h
from collections import defaultdict
from collections import deque
for _ in range(int(input())):
	x = int(input())
	l = len(str(x))
	ans = 0
	f = 0
	for i in range(1, 10):
		for j in range(1, 7 + 1):
			val = str(str(i) * j)
			if int(val) == x:
				ans += j
				f = 1
				break
			elif int(val) <= 10000:
				ans += j
			else:
				break
		if f == 1:
			break
	print(ans)


for i in range(int(input())):
	x = int(input())
	digit = x % 10
	ans = 10 * (digit - 1) + len(str(x)) * (len(str(x)) + 1) // 2
	print(ans)


t = int(input())
while t > 0:
	n = input()
	d = int(n) % 10
	x = len(n)
	cnt = (d - 1) * 10
	for i in range(1, x + 1):
		cnt += i
	print(cnt)
	t -= 1


t = int(input())
for tt in range(t):
	x = int(input())
	xi = x % 10 - 1
	s = 0
	ss = 0
	while x > 0:
		s += 1
		ss += s
		x = x // 10
	a = xi * 10 + ss
	print(a)


from collections import Counter, defaultdict
I = lambda : int(input())
M = lambda : map(int, input().split())
LI = lambda : list(map(int, input().split()))
for _ in range(I()):
	n = I()
	a = [1, 11, 111, 1111, 2, 22, 222, 2222, 3, 33, 333, 3333, 4, 44, 444, 4444, 5, 55, 555, 5555, 6, 66, 666, 6666, 7, 77, 777, 7777, 8, 88, 888, 8888, 9, 99, 999, 9999]
	ans = 0
	for i in range(len(a)):
		x = a[i]
		while a[i] > 0:
			ans += 1
			a[i] //= 10
		if x == n:
			break
	print(ans)


t = int(input())
for i in range(t):
	d = str(input())
	temp = 0
	arr = [1, 2, 3, 4]
	dl = int(d)
	while dl % 10 > 0:
		temp += 10
		dl -= 1
	if len(d) < 4:
		temp -= sum(arr[len(d):])
	print(temp)


for _ in range(0, int(input())):
	n = list(map(int, input()))
	num = n[0]
	l = len(n)
	total = (num - 1) * 10 + sum(range(1, l + 1))
	print(total)


for _ in range(int(input())):
	n = input()
	np = len(n)
	ndigitspres = int((int(n[0]) - 1) * 10 + np * (np + 1) / 2)
	print(ndigitspres)


for _ in range(int(input())):
	n = int(input())
	n2 = str(n)
	already = int(str(n)[0])
	print(int((already - 1) * (4 * 5) / 2 + len(n2) * (len(n2) + 1) / 2))


for test in range(int(input())):
	x = int(input())
	li = []
	for c in range(1, 10):
		num = 0
		while num <= 10000:
			num = num * 10 + c
			if num <= 10000:
				li.append(num)
	ans = 0
	for value in li:
		tmp = value
		while tmp > 0:
			ans += 1
			tmp = tmp // 10
		if value == x:
			break
	print(ans)


for _ in range(int(input())):
	x = input()
	jawab = [1, 2, 3, 4]
	panjang = len(x)
	digit = int(x[0])
	print(10 * (digit - 1) + sum(jawab[:panjang]))


t = int(input())
for i in range(t):
	x = input()
	n = int(x[0])
	s = [0, 1, 3, 6, 10]
	y = len(x)
	print(10 * (n - 1) + s[y])


t = int(input())

def BooringApartment():
	answeres_call = input()
	l = len(answeres_call)
	first_digit = int(answeres_call[0])
	l = l * (l + 1) // 2
	answeres_call = int(answeres_call)
	keypressed = l + (first_digit - 1) * 10
	return keypressed
result = []
for i in range(t):
	result.append(BooringApartment())
for i in result:
	print(i)


t = int(input())
for i in range(t):
	x = input().strip()
	ans = (int(x[0]) - 1) * 10
	for i in range(len(x)):
		ans += i + 1
	print(ans)


t = int(input())
for k in range(t):
	x = int(input())
	n = (x % 10 - 1) * 10
	if len(str(x)) == 1:
		c = 1
	elif len(str(x)) == 2:
		c = 3
	elif len(str(x)) == 3:
		c = 6
	elif len(str(x)) == 4:
		c = 10
	print(c + n)


def counter(x):
	if x == 1:
		return 1
	return x + counter(x - 1)
for _ in range(int(input())):
	x = input()
	int_x = len(x)
	if x[0] == '1':
		print(counter(int_x))
	if x[0] == '2':
		print(10 + counter(int_x))
	if x[0] == '3':
		print(20 + counter(int_x))
	if x[0] == '4':
		print(30 + counter(int_x))
	if x[0] == '5':
		print(40 + counter(int_x))
	if x[0] == '6':
		print(50 + counter(int_x))
	if x[0] == '7':
		print(60 + counter(int_x))
	if x[0] == '8':
		print(70 + counter(int_x))
	if x[0] == '9':
		print(80 + counter(int_x))


lst = [0, 1, 3, 6, 10]
for t in range(int(input())):
	a = input()
	print((int(a[0]) - 1) * 10 + lst[len(a)])


t = int(input())
for i in range(t):
	x = int(input())
	b = x % 10
	c = 0
	while x > 0:
		c += 1
		x //= 10
	s = (1 + 2 + 3 + 4) * (b - 1) + sum([i for i in range(1, c + 1)])
	print(s)


y122 = int(input())
for _ in range(y122):
	n = int(input())
	a = n % 10
	s = (a - 1) * 10
	k = 1
	while n != 0:
		n = n // 10
		s += k
		k += 1
	print(s)


import os
import sys
from io import BytesIO, IOBase
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
input = lambda : sys.stdin.readline().rstrip('\r\n')
import math
from collections import Counter, defaultdict, deque

def int1():
	return int(input())

def map1():
	return map(int, input().split())

def list1():
	return list(map(int, input().split()))
mod = pow(10, 9) + 7

def solve():
	n = input()
	l1 = []
	for i in range(1, 10):
		for j in range(1, 5):
			v = str(i) * j
			l1.append(v)
	count = 0
	for i in l1:
		if i == n:
			count += len(i)
			print(count)
		count += len(i)
for _ in range(int(input())):
	solve()


t = int(input())
for _ in range(t):
	n = int(input())
	l = len(str(n))
	num = int(str(n)[0])
	res = 0
	res = (num - 1) * 10
	if l == 1:
		res += 1
	elif l == 2:
		res += 3
	elif l == 3:
		res += 6
	else:
		res += 10
	print(res)


t = int(input())
for i in range(t):
	n = int(input())
	d = n % 10
	s = (d - 1) * 10 + 1
	if n > 10:
		s += 2
	if n > 100:
		s += 3
	if n > 1000:
		s += 4
	print(s)


t = int(input())
a = []
flat = 1
stroka = ''
mnog = 1
for i in range(t):
	x = int(input())
	a.append(x)
x = 0
for i in a:
	while flat != i:
		stroka += str(flat)
		x += 1
		flat = flat * 10 + mnog
		if x == 4:
			x = 0
			mnog += 1
			flat = mnog
	x = 0
	mnog = 1
	flat = 1
	stroka += str(i)
	print(len(stroka))
	stroka = ''


from sys import stdin

def main(x):
	previous = x % 10 - 1
	print(previous * 10 + sum(range(1, len(str(x)) + 1)))
t = int(stdin.readline())
cases = [int(stdin.readline()) for _ in range(t)]
for x in cases:
	main(x)


def problem_sol(x):
	s = 0
	found = False
	for i in range(1, 10):
		if found:
			break
		for j in range(1, 5):
			if j * str(i) == str(x):
				s += j
				found = True
				break
			else:
				s += j
	print(s)
no_inp = int(input())
while no_inp > 0:
	x = int(input())
	problem_sol(x)
	no_inp -= 1


from math import sqrt

def solve(n):
	index = 0
	s = 0
	g = [1, 11, 111, 1111, 2, 22, 222, 2222, 3, 33, 333, 3333, 4, 44, 444, 4444, 5, 55, 555, 5555, 6, 66, 666, 6666, 7, 77, 777, 7777, 8, 88, 888, 8888, 9, 99, 999, 9999]
	for i in range(0, len(g)):
		if n == g[i]:
			index = i
			break
	for i in range(0, index + 1):
		s += len(str(g[i]))
	print(s)

def main():
	for i in range(0, int(input())):
		solve(int(input()))
main()


T = int(input())
for _ in range(0, T):
	n = int(input())
	ans = 0
	flag = 0
	for i in range(1, 10):
		tt = str(i)
		for j in range(1, 7):
			tt = str(i) * j
			tt = int(tt)
			if tt <= 10000:
				ans += len(str(tt))
				if tt == n:
					flag = 1
					break
			else:
				break
		if flag == 1:
			break
	print(ans)


n = input()
Arr = [0] * int(n)
for i in range(int(n)):
	x = input()
	Arr[i] = x
for i in range(int(n)):
	x = int(Arr[i])
	kq = (x % 10 - 1) * 10 + len(Arr[i]) * (len(Arr[i]) + 1) / 2
	print(int(kq))


t = int(input())
for i in range(t):
	x = input()
	c = len(x)
	lx = [int(i) for i in str(x)]
	f = lx[0]
	ff = (f - 1) * 10
	res = 0
	if c == 1:
		res = ff + 1
		print(res)
	if c == 2:
		res = ff + (c + 1)
		print(res)
	if c == 3:
		res = ff + (c + 3)
		print(res)
	if c == 4:
		res = ff + (c + 6)
		print(res)


t = int(input())
for _ in range(t):
	s = input()
	n = int(s[0])
	l = len(s)
	prevs = (n - 1) * 10
	remain = (1 + l) * l // 2
	print(prevs + remain)


def check_boring(num):
	i = 0
	count = 1
	sum_apart = 0
	while i != int(num):
		if i < 1000 and count < 10:
			i = i * 10 + count
			n = i
			while n > 0:
				sum_apart += 1
				n = n // 10
		elif count < 10:
			count += 1
			i = 0
		else:
			break
	return sum_apart
test = int(input())
boring_num = []
for i in range(test):
	boring_num.append(input())
check = ''
check = '\n'.join([str(check_boring(boring_num[i])) for i in range(0, len(boring_num))])
print(check)


t = int(input())
for _t in range(t):
	x = int(input())
	out = 0
	for i in range(1, 10):
		for l in range(1, 5):
			out += l
			if int(str(i) * l) == x:
				break
		else:
			continue
		break
	print(out)


import sys
input = sys.stdin.readline
t = int(input())
for i in range(t):
	s = input()
	mok = int(s[0])
	ans = 0
	ans += (mok - 1) * 10
	nam = len(s) - 1
	if nam == 1:
		ans += 1
	elif nam == 2:
		ans += 3
	elif nam == 3:
		ans += 6
	elif nam == 4:
		ans += 10
	print(ans)


n = int(input())
x = [1, 2, 3, 4, 5, 6, 7, 8, 9]
y = [1, 11, 111, 1111]

def answer(m):
	global x, y
	ans = 0
	for i in x:
		for j in range(4):
			ans += j + 1
			if i * y[j] == m:
				return ans
ans_lst = []
for i in range(n):
	m = int(input())
	ans_lst.append(answer(m))
for i in range(n):
	print(ans_lst[i])


for _ in range(int(input())):
	a = input()
	l = len(a)
	d = int(a) % 10
	ans = 10 * (d - 1) + l * (l + 1) // 2
	print(ans)


arith_sum = lambda n: int((n + n ** 2) / 2)
t = int(input())
for _ in range(t):
	n = input()
	d = int(n) % 10
	print(arith_sum(len(n)) + (d - 1) * arith_sum(4))


t = int(input())
while t:
	t -= 1
	n = int(input())
	(r, l, q) = (0, len(str(n)), n % 10)
	for i in range(q - 1):
		r += 10
	lst = [i for i in range(1, l + 1)]
	print(r + sum(lst))


try:
	n = int(input())
	s = []
	l = []
	re = []
	for i in range(n):
		y = int(input())
		s.append(y)
	for i in range(1, 10):
		for j in range(1, 5):
			l.append(str(i) * j)
	for x in s:
		for (ind, i) in enumerate(l):
			if i == str(x):
				re.append(sum((len(h) for h in l[:ind + 1])))
			else:
				continue
	for v in re:
		print(v)
except EOFError:
	pass


t = int(input())
for i in range(0, t):
	n = input()
	num = int(n[0])
	count = 0
	for j in range(0, num - 1):
		count += 10
	if len(n) == 1:
		count += 1
	elif len(n) == 2:
		count += 3
	elif len(n) == 3:
		count += 6
	else:
		count += 10
	print(count)


conteo = {1: 1, 2: 3, 3: 6, 4: 10}

def digitos(numero):
	sumatoria = 0
	inicial = str(numero)
	longitud = len(inicial)
	sumatoria += conteo[longitud]
	primero = int(inicial[0])
	rango = range(1, primero)
	sumatoria += len(rango) * 10
	return sumatoria
test = int(input())
for i in range(test):
	numero = int(input())
	print(digitos(numero))


import sys
import math
input = sys.stdin.readline

def algo(s):
	n = int(s[0])
	total = (n - 1) * 10
	return total + len(s) * (1 + len(s)) // 2
for _ in range(int(input())):
	s = input().strip()
	res = algo(s)
	print(res)


a = int(input())
ch = []
for every in range(a):
	ch.append(int(input()))
sp = []

def rt(n):
	k = 1
	b = 0
	for m in range(4):
		b = b + k * n
		sp.append(b)
		k *= 10
for every in range(1, 10):
	rt(every)
count = 0
for every in ch:
	for ever in sp:
		if every != ever:
			count += len(str(ever))
		elif every == ever:
			count += len(str(ever))
			break
	print(count)
	count = 0


t = int(input())
a = 1
b = 0
for i in range(t):
	x = int(input())
	if str(x) == '111':
		b = 6
	if len(str(x)) == 4:
		for i in range(1, 10):
			if str(i) in str(x):
				a = i * 10
	elif len(str(x)) == 3 and x != 111:
		for i in range(1, 10):
			if str(i) in str(x):
				a = i * 10 - 4
	elif len(str(x)) == 2 and x != 11:
		for i in range(1, 10):
			if str(i) in str(x):
				a = i * 10 - 7
	elif len(str(x)) == 1 and x != 1:
		for i in range(1, 10):
			if str(i) in str(x):
				a = i * 10 - 9
	if str(x) == '1':
		b = 1
	elif str(x) == '11':
		b = 3
	if '1' in str(x) and x != 1111:
		print(b)
	else:
		print(a)


import math

def run():
	n = int(input())
	v = n % 10
	sum = 0
	vv = 1
	while n != 0:
		n = n // 10
		sum += vv
		vv += 1
	return (v - 1) * 10 + sum
n = int(input())
while n:
	print(run())
	n -= 1


t = int(input())
k = []
while t > 0:
	a = int(input())
	a = str(a)
	if len(a) == 4:
		k.append(10 * int(a[0]))
	if len(a) == 3:
		k.append(10 * int(a[0]) - 4)
	if len(a) == 2:
		k.append(10 * int(a[0]) - 7)
	if len(a) == 1:
		k.append(10 * int(a[0]) - 9)
	t = t - 1
kq = 0
while kq < len(k):
	print(k[kq])
	kq = kq + 1


for i in range(int(input())):
	a = int(input())
	ds = {1: 1, 2: 3, 3: 6, 4: 10}
	t1 = (a % 10 - 1) * 10 + ds[len(str(a))]
	print(t1)


t = int(input())
for _ in range(t):
	x = int(input())
	aux = [1, 3, 6, 10]
	res = (int(str(x)[0]) - 1) * 10 + aux[len(str(x)) - 1]
	print(res)


q = int(input())
while q > 0:
	q = q - 1
	count = 0
	s = int(input())
	if s > 10 or s == 1:
		while s > 10:
			count = count + 1
			s = s // 10
		answer = (s - 1) * 10 + (count + 1) * (count + 2) / 2
	else:
		answer = (s - 1) * 10 + 1
	print(int(answer))


n = int(input())
ns = '123456789'

def total(snum):
	for c in snum:
		total = 0
		for n in ns:
			s = ''
			for times in range(4):
				total += times + 1
				s += n
				if s == snum:
					return total
for times in range(n):
	print(total(input()))


t = int(input())
for i in range(t):
	n = int(input())
	s = str(n)
	length = len(str(n))
	idx = (int(s[0]) - 1) * 4 + 1
	res = 10 * (int(s[0]) - 1)
	for i in range(length):
		res += i + 1
	print(res)


for _ in range(int(input())):
	x = int(input())
	m = x % 10 - 1
	som = m * 10
	if len(str(x)) == 1:
		print(som + 1)
		continue
	if len(str(x)) == 2:
		print(som + 3)
		continue
	if len(str(x)) == 3:
		print(som + 6)
		continue
	if len(str(x)) == 4:
		print(som + 10)
		continue


for _ in range(int(input())):
	a = int(input())
	x = int(str(a)[0]) * 10
	if len(str(a)) == 3:
		x = x - 4
	elif len(str(a)) == 2:
		x = x - 7
	elif len(str(a)) == 1:
		x = x - 9
	print(x)


x = input()
inps = []
res = 0
AP = [1, 2, 3, 4]
for _ in range(int(x)):
	inps.append(int(input()))
for xx in inps:
	res = 0
	if xx == 1:
		print('1')
		continue
	else:
		snum = str(xx)[0]
		numdig = len(str(xx))
		base = sum(AP) * (int(snum) - 1)
		baseplus = sum(AP[0:numdig])
		res = base + baseplus
	print(res)


t = int(input())
for i in range(t):
	n = int(input())
	k = 0
	for i in range(n % 10 - 1):
		k += 10
	for i in range(len(str(n)) + 1):
		k += i
	print(k)


t = int(input())
for _ in range(t):
	x = int(input())
	acc = 10 * (int(str(x)[0]) - 1)
	for i in range(len(str(x)) + 1):
		acc += i
	print(acc)


t = int(input())
for i in range(t):
	n = input()
	no = int(n)
	k = no % 10
	ans = 0
	if k == 1:
		for j in range(1, len(n) + 1):
			ans += j
	else:
		for j in range(1, len(n) + 1):
			ans += j
		ans += 10 * (k - 1)
	print(ans)


t = int(input())
for i in range(t):
	num = int(input())
	count = 0
	val = int(num % 10)
	for j in range(1, val + 1):
		if j == val:
			temp = str(num)
			for k in range(len(temp)):
				count = count + k + 1
		else:
			count = count + 10
	print(count)


t = int(input())
ans = []
for i in range(t):
	num = input()
	result = 0
	for j in range(len(num) + 1):
		result += j
	n = int(num[0])
	result += (n - 1) * 10
	ans.append(result)
for i in range(t):
	print(ans[i])


a = int(input())
for i in range(a):
	b = input()
	count = 0
	n = list(set(b))
	g = 0
	h = ''
	while h != b:
		h += n[0]
		g += len(h)
	count = (int(n[0]) - 1) * 10 + g
	print(count)


def solve():
	n = input()
	print(int(n) % 10 * 10 + len(n) * (len(n) + 1) // 2 - 10)
for i in range(int(input())):
	solve()


t = int(input())
for i in range(t):
	n = input()
	p = len(n)
	n = int(n)
	k = n % 10
	if k == 1:
		if p == 1:
			print(1)
		elif p == 2:
			print(3)
		elif p == 3:
			print(6)
		elif p == 4:
			print(10)
	elif k == 2:
		if p == 1:
			print(11)
		elif p == 2:
			print(13)
		elif p == 3:
			print(16)
		elif p == 4:
			print(20)
	elif k == 3:
		if p == 1:
			print(21)
		elif p == 2:
			print(23)
		elif p == 3:
			print(26)
		elif p == 4:
			print(30)
	elif k == 4:
		if p == 1:
			print(31)
		elif p == 2:
			print(33)
		elif p == 3:
			print(36)
		elif p == 4:
			print(40)
	elif k == 5:
		if p == 1:
			print(41)
		elif p == 2:
			print(43)
		elif p == 3:
			print(46)
		elif p == 4:
			print(50)
	elif k == 6:
		if p == 1:
			print(51)
		elif p == 2:
			print(53)
		elif p == 3:
			print(56)
		elif p == 4:
			print(60)
	elif k == 7:
		if p == 1:
			print(61)
		elif p == 2:
			print(63)
		elif p == 3:
			print(66)
		elif p == 4:
			print(70)
	elif k == 8:
		if p == 1:
			print(71)
		elif p == 2:
			print(73)
		elif p == 3:
			print(76)
		elif p == 4:
			print(80)
	elif k == 9:
		if p == 1:
			print(81)
		elif p == 2:
			print(83)
		elif p == 3:
			print(86)
		elif p == 4:
			print(90)


import sys
input = sys.stdin.readline

def inp():
	return int(input())

def inlt():
	return list(map(int, input().split()))

def insr():
	s = input()
	return s.strip()

def invr():
	return map(int, input().split())
t = inp()

def solve(x):
	num_digits = 0
	r = x
	while r:
		num_digits += 1
		r = r // 10
	first_dig = x // 10 ** (num_digits - 1)
	return int(10 * (first_dig - 1) + num_digits * (num_digits + 1) / 2)
while t:
	x = int(input())
	print(solve(x))
	t -= 1


def count(table, k):
	plus = 0
	for i in range(len(str(table[k]))):
		plus += 1
	return plus
table = []
for i in range(1, 10):
	num = str(i)
	table.append(int(num))
	for j in range(3):
		num += str(i)
		table.append(int(num))
t = int(input())
for i in range(t):
	k = 0
	c = 0
	x = int(input())
	while True:
		c += count(table, k)
		if x == table[k]:
			break
		k += 1
	print(c)


import sys
reader = (s.rstrip() for s in sys.stdin)
input = reader.__next__
t = int(input())

def solve(X):
	terms = [1, 11, 111, 1111]
	c = 0
	for x in range(1, 10):
		for k in terms:
			c += len(str(x * k))
			if X == x * k:
				return c
for _ in range(t):
	X = int(input())
	print(solve(X))


t = int(input())
for i in range(t):
	x = int(input())
	y = 0
	if len(str(x)) == 1:
		y += 1
	if len(str(x)) == 2:
		y += 3
	if len(str(x)) == 3:
		y += 6
	if len(str(x)) == 4:
		y += 10
	z = str(x)[0]
	y = y + 10 * (int(z) - 1)
	print(y)


def input_n_lines(a):
	return [int(input()) for i in range(0, a)]
boring_apartments = [1, 11, 111, 1111, 2, 22, 222, 2222, 3, 33, 333, 3333, 4, 44, 444, 4444, 5, 55, 555, 5555, 6, 66, 666, 6666, 7, 77, 777, 7777, 8, 88, 888, 8888, 9, 99, 999, 9999]
n = int(input())
inpt = input_n_lines(n)
output = []
counter = 0
for x in inpt:
	for y in boring_apartments:
		if boring_apartments.index(y) < boring_apartments.index(x):
			counter += len(str(y))
		elif boring_apartments.index(y) == boring_apartments.index(x):
			counter += len(str(y))
			output.append(counter)
			counter -= counter
for v in output:
	print(v)


for _ in range(int(input())):
	n = int(input())
	p = 0
	for i in range(1, 10):
		c = 1
		f = 0
		s = 0
		while c <= 4:
			s = s * 10 + i
			p = p + c
			if s == n:
				f = 1
				print(p)
				break
			c += 1
		if f == 1:
			break


l = []
for _ in range(int(input())):
	x = list(input())
	a = int(x[0])
	sum = 10 * (a - 1)
	for i in range(1, len(x) + 1):
		sum = sum + i
	l.append(sum)
for i in l:
	print(i)


for _ in range(int(input())):
	n = int(input())
	s = str(n)
	d = int(s[0]) - 1
	d = d * 10
	if len(s) == 1:
		d += 1
	if len(s) == 2:
		d += 3
	if len(s) == 3:
		d += 6
	if len(s) == 4:
		d += 10
	print(d)


t = int(input())

def nd(n):
	cnt = 0
	while n:
		n = n // 10
		cnt = cnt + 1
	return cnt
for tn in range(1, t + 1):
	n = int(input())
	num = 1
	ad = 1
	ch = 1
	count = 0
	while num != n:
		ndd = nd(num)
		if ndd >= 4:
			ch = ch + 1
			ad = ch
			num = ch
			count = count + 1
			continue
		ad = ad * 10
		num = num + ad
		count = count + nd(num)
	print(count + 1)


def solve(x):
	summa = (int(x[0]) - 1) * 10
	if len(x) == 1:
		return summa + 1
	elif len(x) == 2:
		return summa + 3
	elif len(x) == 3:
		return summa + 6
	else:
		return summa + 10
t = int(input())
for i in range(0, t):
	print(solve(input()))


a = []
for i in range(1, 10):
	s = str(i)
	a.append(s)
	s = s + str(i)
	a.append(s)
	s = s + str(i)
	a.append(s)
	s = s + str(i)
	a.append(s)
t = int(input())
for _ in range(t):
	ans = 0
	x = int(input())
	for i in a:
		if i == str(x):
			ans += len(i)
			break
		else:
			ans += len(i)
	print(ans)


def fac(x):
	if x == 0 or x == 1:
		return 1
	else:
		return x + fac(x - 1)
a = []
for i in range(int(input())):
	a.append(input())
for s in a:
	k = len(s)
	print(10 * (int(s[0]) - 1) + fac(k))


from collections import defaultdict as dd, deque as dq, Counter as c
from math import factorial as f, ceil, gcd, sqrt
for _ in range(int(input())):
	a = int(input())
	t = str(a)
	k = int(t[0]) - 1
	ans = k * 10
	ans += len(t) * (len(t) + 1) // 2
	print(ans)


d = {}
g = 1
for i in range(1, 10):
	prev = 1
	for j in range(1, 5):
		d[str(i) * j] = g
		prev += 1
		if prev == 5:
			prev = 1
		g += prev
for i in range(int(input())):
	x = int(input())
	print(d[str(x)])


def BoringApt():
	t = int(input(''))
	finalOuptput = []
	for j in range(t):
		x = input('')
		BoringNumbers = []
		boringRange = []
		for i in range(1, 10000):
			if len(str(i)) == str(i).count(str(i)[0]):
				BoringNumbers.append(str(i))
		BoringNumbers = sorted(BoringNumbers)
		output = 0
		for i in BoringNumbers[0:BoringNumbers.index(x) + 1]:
			output += len(str(i))
		finalOuptput.append(output)
	for i in finalOuptput:
		print(i, end='\n')
BoringApt()


for _ in range(int(input())):
	n = input()
	val = n[0]
	val = int(val)
	ans = 0
	ans += (val - 1) * 10
	a = len(n)
	ans += a * (a + 1) // 2
	print(ans)


def count_keypress(numb):
	first_digit = numb % 10
	n = len(str(numb))
	print(int((first_digit - 1) * 10 + n * (n + 1) / 2))
tot = input()
tot = int(tot)
list_num = []
for i in range(1, tot + 1):
	list_num.append(int(input()))
for j in list_num:
	count_keypress(j)


for i in range(int(input())):
	num = input()
	sum = 0
	for j in range(1, int(num[0])):
		sum = sum + 10
	if len(num) == 4:
		print(sum + 10)
	elif len(num) == 3:
		print(sum + 6)
	elif len(num) == 2:
		print(sum + 3)
	else:
		print(sum + 1)


a = input()
a = int(a)
b = []
for i in range(1, 10):
	i = str(i)
	for j in range(1, 5):
		b.append(i * j)
for i in range(a):
	c = input()
	v = 0
	for i in b:
		if i == c:
			v = b.index(i)
			break
	g = 0
	pos = 0
	while True:
		if pos == v + 1:
			break
		g = g + len(b[pos])
		pos += 1
	print(g)


t = int(input())
l = []
for i in range(t):
	x = input()
	y = int(x[0])
	z = int(len(x))
	p = [j for j in range(1, z + 1)]
	s = 10 * (y - 1) + sum(p)
	l.append(s)
for i in l:
	print(i)


t = int(input())
call_answered_list = []
keypress = 0
for i in range(t):
	call_answered = input()
	call_answered_list.append(call_answered)
for test_case in call_answered_list:
	keypress = 0
	boring_list = ['1', '11', '111', '1111', '2', '22', '222', '2222', '3', '33', '333', '3333', '4', '44', '444', '4444', '5', '55', '555', '5555', '6', '66', '666', '6666', '7', '77', '777', '7777', '8', '88', '888', '8888', '9', '99', '999', '9999']
	for i in range(len(boring_list)):
		if test_case == boring_list[i]:
			boring_list = boring_list[:i + 1]
			break
	for i in boring_list:
		keypress += len(i)
	print(keypress)


arr = [1, 11, 111, 1111, 2, 22, 222, 2222, 3, 33, 333, 3333, 4, 44, 444, 4444, 5, 55, 555, 5555, 6, 66, 666, 6666, 7, 77, 777, 7777, 8, 88, 888, 8888, 9, 99, 999, 9999]
length = [1, 2, 3, 4]
for _ in range(int(input())):
	n = int(input())
	sum_length = 0
	for i in range(len(arr)):
		if n == arr[i]:
			sum_length += length[i % 4]
			break
		else:
			sum_length += length[i % 4]
	print(sum_length)


n = int(input())
for i in range(n):
	a = int(input())
	k = (a % 10 - 1) * 10
	for i in range(1, len(str(a)) + 1):
		k += i
	print(k)


n = int(input())
for i in range(n):
	a = int(input())
	b = a % 10
	c = a // b * 9 + 1
	d = 10 * (b - 1)
	if c == 10:
		print(d + 1)
	elif c == 100:
		print(d + 3)
	elif c == 1000:
		print(d + 6)
	else:
		print(d + 10)


from functools import reduce
import os
import sys
from collections import *
from math import *
from bisect import *
from heapq import *
from io import BytesIO, IOBase
input = lambda : sys.stdin.readline().rstrip('\r\n')

def value():
	return tuple(map(int, input().split()))

def arr():
	return [int(i) for i in input().split()]

def sarr():
	return [int(i) for i in input()]

def starr():
	return [str(x) for x in input().split()]

def inn():
	return int(input())

def svalue():
	return tuple(map(str, input().split()))

def parr():
	return [value() for i in range(n)]
mo = 1000000007
inf = 1e+18
div = 998244353
d = defaultdict(int)
sm = 0
for i in range(1, 10):
	for j in range(1, 5):
		sm += j
		res = int(str(i) * j)
		d[res] = sm
for _ in range(inn()):
	n = inn()
	print(d[n])


for _ in range(int(input())):
	n = int(input())
	m = str(n)
	l = len(m)
	a = int(m[0]) - 1
	s = 10 * a + l * (l + 1) // 2
	print(s)


def soma(n):
	if n == 1:
		return 1
	return n + soma(n - 1)
n = int(input())
for e in range(n):
	apt = input()
	num = int(apt[0])
	resp = 0
	resp += soma(len(apt))
	num -= 1
	while num > 0:
		resp += 10
		num -= 1
	print(resp)


t = int(input())
for i in range(t):
	x = int(input())
	summ = 0
	for j in range(int(str(x)[0]) - 1):
		summ += 10
	if len(str(x)) == 1:
		summ += 1
	elif len(str(x)) == 2:
		summ += 3
	elif len(str(x)) == 3:
		summ += 6
	elif len(str(x)) == 4:
		summ += 10
	print(summ)


def boring_apartments(num):
	digits_pressed = 0
	for i in range(1, int(str(num)[0])):
		digits_pressed = digits_pressed + 10
	for i in range(1, len(str(num)) + 1):
		digits_pressed += i
	return digits_pressed
t = int(input())
for i in range(t):
	n = int(input())
	print(boring_apartments(n))


for _ in range(int(input())):
	n = int(input())
	x = [1, 11, 111, 1111, 2, 22, 222, 2222, 3, 33, 333, 3333, 4, 44, 444, 4444, 5, 55, 555, 5555, 6, 66, 666, 6666, 7, 77, 777, 7777, 8, 88, 888, 8888, 9, 99, 999, 9999]
	res = x.index(n)
	y = [1, 2, 3, 4, 1, 2, 3, 4, 1, 2, 3, 4, 1, 2, 3, 4, 1, 2, 3, 4, 1, 2, 3, 4, 1, 2, 3, 4, 1, 2, 3, 4, 1, 2, 3, 4]
	print(sum(y[:res + 1]))


test_case = int(input())
for _ in range(test_case):
	n = input()
	ans = 0
	(val, idx) = (int(n[0]), len(n))
	for i in range(1, val):
		ans += 10
	for i in range(1, idx + 1):
		ans += i
	print(ans)


def main():
	for _ in range(int(input())):
		ans = 0
		x = input()
		if x[0] != 1:
			ans = int(x[0]) * 10 - 10
		y = len(x)
		if y == 1:
			ans += 1
		elif y == 2:
			ans += 3
		elif y == 3:
			ans += 6
		else:
			ans += 10
		print(ans)
main()


t = int(input())
for i in range(t):
	a = int(input())
	c = len(str(a))
	b = str(a)[0]
	if c == 1:
		s = (int(b) - 1) * 10 + 1
		print(s)
	elif c == 2:
		s = (int(b) - 1) * 10 + 3
		print(s)
	elif c == 3:
		s = (int(b) - 1) * 10 + 6
		print(s)
	elif c == 4:
		s = (int(b) - 1) * 10 + 10
		print(s)


import sys
import os
from math import sqrt, log, log2, log10, gcd, floor, pow, sin, cos, tan, pi, inf, factorial
from copy import copy, deepcopy
from sys import exit, stdin, stdout
from collections import Counter, defaultdict, deque
from itertools import permutations
import heapq
from bisect import bisect_left as bl
from bisect import bisect_right as br
from bisect import bisect
mod = 1000000007
iinp = lambda : int(sys.stdin.readline())
inp = lambda : sys.stdin.readline().strip()
strl = lambda : list(inp().strip().split(' '))
intl = lambda : list(map(int, inp().split(' ')))
mint = lambda : map(int, inp().split())
flol = lambda : list(map(float, inp().split(' ')))
flush = lambda : stdout.flush()

def permute(nums):

	def fun(arr, nums, cur, v):
		if len(cur) == len(nums):
			arr.append(cur.copy())
		i = 0
		while i < len(nums):
			if v[i]:
				i += 1
				continue
			else:
				cur.append(nums[i])
				v[i] = 1
				fun(arr, nums, cur, v)
				cur.pop()
				v[i] = 0
				i += 1
		return arr
	res = []
	nums.sort()
	v = [0] * len(nums)
	return fun(res, nums, [], v)

def subsets(res, index, arr, cur):
	res.append(cur.copy())
	for i in range(index, len(arr)):
		cur.append(arr[i])
		subsets(res, i + 1, arr, cur)
		cur.pop()
	return res

def sieve(N):
	root = int(sqrt(N))
	primes = [1] * (N + 1)
	(primes[0], primes[1]) = (0, 0)
	for i in range(2, root + 1):
		if primes[i]:
			for j in range(i * i, N + 1, i):
				primes[j] = 0
	return primes

def bs(arr, l, r, x):
	if x < arr[0] or x > arr[len(arr) - 1]:
		return -1
	while l <= r:
		mid = l + (r - l) // 2
		if arr[mid] == x:
			return mid
		elif arr[mid] < x:
			l = mid + 1
		else:
			r = mid - 1
	return -1

def isPrime(n):
	if n <= 1:
		return False
	if n <= 3:
		return True
	if n % 2 == 0 or n % 3 == 0:
		return False
	p = int(sqrt(n))
	for i in range(5, p + 1, 6):
		if n % i == 0 or n % (i + 2) == 0:
			return False
	return True

def solve():
	n = iinp()
	ans = 0
	arr = [1, 2, 3, 4, 5, 6, 7, 8, 9]
	for i in range(len(arr)):
		s = str(arr[i])
		while len(s) <= 4:
			if int(s) == n:
				ans += len(s)
				return ans
			else:
				ans += len(s)
				s += s[0]
for _ in range(iinp()):
	print(solve())


from sys import stdin, stdout

def readArr():
	return list(map(int, stdin.readline().strip().split()))

def readLine():
	return stdin.readline().strip()

def readInt():
	return int(stdin.readline().strip())
n = int(input())
for _ in range(n):
	x = int(input())
	s = int(str(x)[:1])
	a = 10 * (s - 1)
	l = len(str(x))
	b = l * (l + 1) // 2
	print(a + b)


room = [1, 11, 111, 1111, 2, 22, 222, 2222, 3, 33, 333, 3333, 4, 44, 444, 4444, 5, 55, 555, 5555, 6, 66, 666, 6666, 7, 77, 777, 7777, 8, 88, 888, 8888, 9, 99, 999, 9999]
t = int(input())
for i in range(t):
	n = int(input())
	x = room.index(n)
	x = x + 1
	vagfol = int(x / 4)
	vagsesh = x % 4
	extra = 0
	for j in range(1, vagsesh + 1):
		extra = extra + j
	ans = vagfol * 10 + extra
	print(ans)


def boring(n, l):
	res = sum([i for i in range(1, l + 1)]) + 10 * (n - 1)
	return res
for _ in range(int(input())):
	s = input()
	print(boring(int(s[0]), len(s)))


for _ in range(int(input())):
	x = int(input())
	s = str(x)
	length = len(s)
	d = int(s[0])
	print((d - 1) * 10 + length * (length + 1) // 2)


casos = int(input())
for i in range(0, casos):
	ap = input()
	pa = 10 * (int(ap) % 10 - 1)
	ac = len(ap)
	cont = 0
	for j in range(1, ac + 1):
		cont += j
	print(pa + cont)


t = int(input())
for i in range(t):
	n = int(input())
	k = n
	a = 0
	q = 0
	while k > 10:
		k = int(k / 10)
		q = q + 1
	for p in range(k):
		if p + 1 < k:
			a = a + 10
		else:
			for j in range(q + 1):
				a = a + (j + 1)
	print(a)


def count(n):
	result = (n % 10 - 1) * 10
	rest = 0
	val = len(str(n))
	if val == 1:
		rest = 1
	elif val == 2:
		rest = 3
	elif val == 3:
		rest = 6
	else:
		rest = 10
	return rest + result
T = int(input())
for i in range(T):
	n = int(input())
	print(count(n))


t = int(input())
for _ in range(t):
	x = input()
	f = 9 * (len(x) - 1) + int(x[0])
	total = 0
	done = False
	for col in range(1, 10):
		if done:
			break
		for row in range(1, 5):
			total += row
			if 9 * (row - 1) + col == f:
				done = True
				break
	print(total)


from collections import defaultdict

class Solution:

	def __init__(self):
		pass

	def run(self):
		x = input()
		n = len(x)
		result = 0
		result += (int(x[0]) - 1) * 10
		result += n * (n + 1) / 2
		return int(result)
t = int(input())
s = Solution()
for i in range(t):
	print(s.run())


def boring(n):
	m = len(str(n))
	k = n % 10
	l = (k - 1) * 10 + m * (m + 1) // 2
	print(l)
T = int(input())
for tc in range(T):
	n = int(input())
	boring(n)


t = int(input())
for _ in range(t):
	n = int(input())
	count = 0
	for i in range(1, int(str(n)[0]) + 1):
		s_i = str(i)
		while len(s_i) <= 4:
			count += len(s_i)
			if s_i == str(n):
				break
			s_i += str(i)
	print(count)


t = int(input())
for i in range(t):
	s = input()
	x = int(s) % 10
	l = len(s)
	ans = 10 * (x - 1)
	ans += l * (l + 1) // 2
	print(ans)


number_of_test_cases = int(input())

def calculateSum(length):
	return length * (length + 1) // 2
for i in range(number_of_test_cases):
	answer = 0
	apartment_answered = input()
	keys_pressed_for_current_digit = calculateSum(len(apartment_answered))
	digit = int(apartment_answered) % 10
	answer += (digit - 1) * calculateSum(4) + keys_pressed_for_current_digit
	print(answer)


t = int(input())
for i in range(t):
	ans = 1
	n = int(input())
	s = '1'
	while str(n) != s:
		if len(s) == 4:
			s = str(int(s[0]) + 1)
		else:
			s += s[0]
		ans += len(s)
	print(ans)


n = int(input())
x = []
for i in range(n):
	x.append(int(input()))
for i in x:
	count = 0
	mod = i % 10
	multiple = (mod - 1) * 10
	while i != 0:
		i //= 10
		count += 1
	print(int(multiple + (count + 1) * count / 2))


for i in range(int(input())):
	x = int(input())
	x1 = '1'
	s = 1
	while x1 != str(x):
		if len(x1) < 4:
			x1 += x1[-1]
		else:
			x1 = str(int(x1[0]) + 1)
		s += len(x1)
	print(s)


for T in range(int(input())):
	s = input()
	print(10 * (int(s[0]) - 1) + len(s) * (len(s) + 1) // 2)


t = int(input())
for x in range(t):
	i = int(input())
	n = (i % 10 - 1) * 10
	a = str(i)
	l = len(a)
	if l == 1:
		n = n + 1
	elif l == 2:
		n = n + 3
	elif l == 3:
		n = n + 6
	elif l == 4:
		n = n + 10
	print(n)


t = int(input())
while t:
	t -= 1
	s = input()
	n = len(s)
	ans = (ord(s[0]) - 48 - 1) * 10 + n * (n + 1) // 2
	print(ans)


n = int(input())
for i in range(n):
	k = int(input())
	if len(str(k)) == 4:
		print(k // 1000 * 10)
	if len(str(k)) == 3:
		print((k // 100 - 1) * 10 + 6)
	if len(str(k)) == 2:
		print((k // 10 - 1) * 10 + 3)
	if len(str(k)) == 1:
		print((k - 1) * 10 + 1)


n = int(input())
for i in range(n):
	s = input()
	x = int(s[0]) - 1
	sum = x * 10
	l = len(s)
	sum += l * (l + 1) / 2
	print(int(sum))


cases = int(input())
for _ in range(cases):
	n = str(input())
	r = (int(n[0]) - 1) * 10
	if len(n) == 1:
		r += 1
	elif len(n) == 2:
		r += 3
	elif len(n) == 3:
		r += 6
	elif len(n) == 4:
		r += 10
	print(r)


t = int(input())
while t > 0:
	a = int(input())
	c = a % 10
	c = c - 1
	ans = c * 10
	b = [1, 2, 3, 4]
	for i in range(0, len(str(a))):
		ans += b[i]
	print(ans)
	t -= 1


t = int(input())
for _ in range(t):
	n = int(input())
	s = 0
	c = 1
	while c != int(str(n)[0]):
		for i in range(4):
			s += i + 1
		c += 1
	for i in range(len(str(n))):
		s += i + 1
	print(s)


import sys
sysinput = sys.stdin.readline
import time
start_time = time.time()

def inp():
	return int(sysinput())

def inlt():
	return list(map(int, sysinput().split()))

def insr():
	s = sysinput()
	return list(s[:len(s) - 1])

def invr():
	return map(int, sysinput().split())
t = inp()
while t > 0:
	t -= 1
	x = inp()
	n = int(str(x)[0])
	l = len(str(x))
	ans = (l + 1) * l // 2 + (n - 1) * 10
	print(ans)


testcase = int(input())
digit = 1
z = 0
for i in range(1, testcase + 1):
	call = int(input())
	digit = 1
	if call < 10:
		digit = (call - 1) * 10 + 1
		print(digit)
	elif call < 100:
		z = call % 10
		digit = (z - 1) * 10 + 3
		print(digit)
	elif call < 1000:
		z = call % 10
		digit = (z - 1) * 10 + 6
		print(digit)
	else:
		z = call % 10
		digit = (z - 1) * 10 + 10
		print(digit)


ref = [0, 1, 3, 6, 10]
tests = int(input())
for t in range(tests):
	stopped = int(input())
	digit = stopped % 10
	presses = (digit - 1) * 10
	stoppedat = len(str(stopped))
	presses += ref[stoppedat]
	print(presses)


import math
import os
import random
import re
import sys

def first_n_digits(num, n):
	return num // 10 ** (int(math.log(num, 10)) - n + 1)

def solve():
	t = int(input())
	for _ in range(t):
		x = int(input())
		first_digit = first_n_digits(x, 1)
		digits_dialed = []
		for i in range(1, first_digit + 1):
			for j in range(1, 5):
				digits_dialed.append(j)
				if i == first_digit and len(str(x)) == j:
					break
		print(sum(digits_dialed))
result = solve()


def digit(n):
	ar = []
	while n > 0:
		ar.append(n % 10)
		n = n // 10
	return ar
x = int(input())
for i in range(0, x):
	n = int(input())
	ar = digit(n)
	d = ar[0]
	p = len(ar)
	f = (d - 1) * 10
	h = p * (p + 1) // 2
	print(f + h)


t = int(input())
st = list()
for i in range(1, 10):
	st.append(str(i))
	st.append(str(i) * 2)
	st.append(str(i) * 3)
	st.append(str(i) * 4)
st.sort()
for _ in range(t):
	s = input()
	ans = 0
	for i in range(0, len(st)):
		if st[i] <= s:
			ans += len(st[i])
	print(ans)


l = []
count = []
for i in range(1, 10):
	now = str(i)
	while int(now) < 10000:
		l.append(now)
		count.append(len(now))
		now += str(i)
for i in range(1, len(count)):
	count[i] += count[i - 1]
for _ in range(int(input())):
	s = input()
	ind = 0
	for i in range(len(l)):
		if l[i] == s:
			ind = i
			break
	print(count[ind])


for _ in range(int(input())):
	n = input()
	leni = len(n)
	p = n[0]
	ans = int(p) - 1
	if leni == 4:
		fans = ans * 10 + 10
		print(fans)
	elif leni == 3:
		fans = ans * 10 + 6
		print(fans)
	elif leni == 2:
		fans = ans * 10 + 3
		print(fans)
	else:
		fans = ans * 10 + 1
		print(fans)


t = int(input())
ans = []
for i in range(t):
	x = int(input())
	if len(str(x)) == 1:
		ans.append(1 + 10 * (x % 10 - 1))
	elif len(str(x)) == 2:
		ans.append(3 + 10 * (x % 10 - 1))
	elif len(str(x)) == 3:
		ans.append(6 + 10 * (x % 10 - 1))
	elif len(str(x)) == 4:
		ans.append(10 + 10 * (x % 10 - 1))
for x in ans:
	print(x)


n = int(input())
l = []
m = [1, 2, 3, 4]
for i in range(0, n):
	s = int(input())
	l.append(s)
for k in range(0, n):
	w = str(l[k])
	fin = int(w[0])
	print(sum(m) * (fin - 1) + sum(m[0:len(w)]))


from sys import stdin, stdout
ans = []
listt = [1, 11, 111, 1111, 2, 22, 222, 2222, 3, 33, 333, 3333, 4, 44, 444, 4444, 5, 55, 555, 5555, 6, 66, 666, 6666, 7, 77, 777, 7777, 8, 88, 888, 8888, 9, 99, 999, 9999]

def main():
	x = int(stdin.readline())
	count = 0
	abb = 1
	for i in listt:
		if str(i) <= str(x):
			count += abb
			abb = abb + 1 if abb != 4 else 1
	ans.append(str(count))
for i in range(int(stdin.readline())):
	main()
stdout.write('\n'.join(ans))


def sum_dig(n):
	return int(n * (n + 1) / 2)
n = int(input())
casos = list()
for i in range(n):
	aux = input()
	casos.append(aux)
for caso in casos:
	for m in range(1, 10):
		if str(m) in caso:
			print((m - 1) * 10 + sum_dig(caso.count(str(m))))
		else:
			continue


from collections import *
from functools import *
import math
import sys
inp = sys.stdin.readline
out = sys.stdout.write

def mi():
	return map(int, inp().split())

def li():
	return list(mi())

def ii():
	return int(inp())

def main():
	for _ in range(ii()):
		x = input()
		s = 1
		ans = 0
		while int(x[0]) != s:
			ans += 1 + 2 + 3 + 4
			s += 1
		a = 1
		while len(x) != a - 1:
			ans += a
			a += 1
		print(ans)
main()


for _ in range(int(input())):
	x = int(input())
	if '1' in str(x):
		n = len(str(x))
		print(n * (n + 1) // 2)
		continue
	prev = int(str(x)[0]) - 1
	tot = 10 * prev
	l = len(str(x))
	print(tot + l * (l + 1) // 2)


T = int(input())
for I in range(0, T):
	N = input()
	A = len(N)
	B = int(N[0])
	print(int((B - 1) * 10 + A * (A + 1) / 2))


import math

def dtb(n):
	return bin(n).replace('0b', '')

def btd(n):
	return int(n, 2)
t = int(input())
for k in range(t):
	n = input()
	x = int(n[0])
	l = len(n)
	ans = 0
	ans = (x - 1) * 10
	if l == 1:
		ans += 1
	if l == 2:
		ans += 3
	if l == 3:
		ans += 6
	if l == 4:
		ans += 10
	print(ans)


p = int(input())
o = []
for i in range(p):
	o.append(int(input()))
for i in range(p):
	mas1 = [[1, 11, 111, 1111], [2, 22, 222, 2222], [3, 33, 333, 3333], [4, 44, 444, 4444], [5, 55, 555, 5555], [6, 66, 666, 6666], [7, 77, 777, 7777], [8, 88, 888, 8888], [9, 99, 999, 9999]]
	g = 0
	z = 0
	l = 0
	l1 = 0
	u = 1
	a = o[i]
	for i in range(9):
		for j in range(4):
			if mas1[i][j] == a:
				g = i + 1
				z = j + 1
	for i in range(g - 1):
		for j in range(4):
			l += len(str(mas1[i][j]))
	for i in range(z):
		l1 += u
		u += 1
	print(l1 + l)


for i in range(int(input())):
	a = int(input())
	i = a % 10
	summ = (i - 1) * 10
	lenn = len(str(a))
	summ += lenn * (lenn + 1) / 2
	print(int(summ))


def brcif(n):
	i = 0
	while n > 0:
		n = n // 10
		i = i + 1
	return i

def sum(n):
	s = 0
	while n > 0:
		s = s + n
		n = n - 1
	return s
t = int(input())
for i in range(t):
	x = int(input())
	k = x % 10
	m = brcif(x)
	print((k - 1) * 10 + sum(m))


t = int(input())
for _ in range(t):
	n = input()
	l = len(n)
	d = int(n[0])
	print(10 * (d - 1) + l * (l + 1) // 2)


for i in range(int(input())):
	n = input()
	r = len(n)
	value = abs(1 - int(n[0])) * 10 + r * (r + 1) // 2
	print(value)


t = int(input())
for tt in range(t):
	x = int(input())
	now = 0
	for i in range(1, 10):
		for j in range(1, 5):
			now += j
			ch = int(str(i) * j)
			if ch == x:
				print(now)
				break


for _ in range(int(input())):
	N = list(input())
	firstnumber = int(N[0])
	total = len(N)
	if total == 1:
		additive = 1
	if total == 2:
		additive = 3
	if total == 3:
		additive = 6
	if total == 4:
		additive = 10
	print((firstnumber - 1) * 10 + additive)


for i in range(int(input())):
	x = int(input())
	b = x % 10
	x = str(x)
	d = x.count(str(b))
	if d == 4:
		p = 10
	elif d == 3:
		p = 6
	elif d == 2:
		p = 3
	else:
		p = 1
	print((b - 1) * 10 + p)


t = int(input())
while t:
	n = int(input())
	s = str(n)
	p = int(s[0])
	if p >= 2:
		c = (p - 1) * 1 + (p - 1) * 2 + (p - 1) * 3 + (p - 1) * 4
		if len(s) == 1:
			c = c + 1
		elif len(s) == 2:
			c = c + 3
		elif len(s) == 3:
			c = c + 6
		elif len(s) == 4:
			c = c + 10
		print(c)
	elif p < 2:
		c = 0
		if len(s) == 1:
			c = c + 1
		elif len(s) == 2:
			c = c + 3
		elif len(s) == 3:
			c = c + 6
		elif len(s) == 4:
			c = c + 10
		print(c)
	t -= 1


def ret(n):
	if n == 1:
		return 1
	elif n == 2:
		return 3
	elif n == 3:
		return 6
	else:
		return 10

def solve():
	x = input()
	if x == '1':
		print('1')
		return
	res = (int(x[0]) - 1) * 10 + ret(len(x))
	print(res)
T = int(input())
for i in range(T):
	solve()


for _ in range(int(input())):
	bore = int(input())
	keys = 0
	num = bore % 10
	keys += (num - 1) * 10
	bore = list(str(bore))
	lent = len(bore)
	while lent:
		keys += lent
		lent -= 1
	print(keys)


t = int(input())
for i in range(t):
	x = int(input())
	pred = 10 * (x % 10 - 1)
	k = 1
	while x // 10 > 0:
		x //= 10
		k += 1
	print(int(pred + (1 + k) / 2 * k))


for _ in range(int(input())):
	x = int(input())
	ans = 0
	temp = x % 10
	ans += (temp - 1) * 10
	for i in range(len(str(x))):
		ans += i + 1
	print(ans)


def f(k):
	s = 10 * (int(k[0]) - 1) + sum([i for i in range(1, len(k) + 1)])
	return s
n = int(input())
for _ in range(n):
	k = input()
	print(f(k))


test_cases = range(int(input()))
for test_case in test_cases:
	ans = input()
	curr_num = ans[0]
	res = (int(curr_num) - 1) * 10
	for i in range(1, len(ans) + 1):
		res += i
	print(res)


for _ in range(int(input())):
	x = list(map(int, input()))
	z = (x[0] - 1) * 10
	if len(x) == 1:
		print(z + 1)
	elif len(x) == 2:
		print(z + 3)
	elif len(x) == 3:
		print(z + 6)
	elif len(x) == 4:
		print(z + 10)


import math
T = int(input())
for t in range(T):
	a = input()
	d = False
	print((int(a[0]) - 1) * 10 + [1, 3, 6, 10][len(a) - 1])


n = int(input())
l = list()
for i in range(n):
	l.append(int(input()))
for i in l:
	a = (i % 10 - 1) * 4 + len(str(i))
	print(a // 4 * 10 + sum([j for j in range(1, a % 4 + 1)]))


t = int(input())
for i in range(t):
	s = input()
	x = int(s[0])
	y = x - 1
	res = y * 10
	if len(s) == 4:
		print(res + 10)
	elif len(s) == 3:
		print(res + 6)
	elif len(s) == 2:
		print(res + 3)
	else:
		print(res + 1)


def test_case_generator() -> int:
	input_num = int(input())
	for i in range(input_num):
		yield int(input())

def lame_problem():
	_fast_translation = [0, 1, 3, 6, 10]
	for test_case in test_case_generator():
		full_iteration_count = test_case % 10 - 1
		partial_iteration_count = _fast_translation[len(str(test_case))]
		result = full_iteration_count * 10 + partial_iteration_count
		print(result)
lame_problem()


testCase = int(input())
while testCase:
	testCase -= 1
	n = input()
	res = (int(n[0]) - 1) * 10 + len(n) * (len(n) + 1) / 2
	print(int(res))


t = int(input())
for m in range(t):
	n = int(input())
	stri = ''

	def func(num):
		stack = []
		ar = [1, 11, 111, 1111]
		for j in range(1, 10):
			for l in ar:
				s = l * j
				if s == n:
					stack.append(s)
					return stack
				else:
					stack.append(s)
	for num in func(n):
		stri += str(num)
	print(len(stri))


t = int(input())
li = [1, 11, 111, 1111]
for j in range(t):
	arr = li[:]
	x = int(input())
	i = 0
	ans = 0
	p = 2
	while i < len(arr):
		ans = ans + (i % 4 + 1)
		arr.append(p * arr[i % 4])
		if len(arr) % 4 == 0:
			p += 1
		if arr[i] == x:
			break
		i += 1
	print(ans)


t = int(input())
for _ in range(t):
	x = input()
	ans = 0
	for i in range(1, 10):
		done = False
		for ln in range(1, 5):
			cur = str(i) * ln
			ans += len(cur)
			if cur == x:
				done = True
				break
		if done:
			break
	print(ans)


for _ in range(int(input())):
	n = int(input())
	d = [[1, 11, 111, 1111], [2, 22, 222, 2222], [3, 33, 333, 3333], [4, 44, 444, 4444], [5, 55, 555, 5555], [6, 66, 666, 6666], [7, 77, 777, 7777], [8, 88, 888, 8888], [9, 99, 999, 9999]]
	s = []
	x = n
	count = 0
	while n > 0:
		b = n % 10
		n = (n - b) // 10
		s.append(b)
	length = len(s)
	last = s[length - 1]
	i = 0
	while last > d[i][0]:
		i += 1
	b = []
	for j in range(4):
		b.append(d[i][j])
	if i != 0:
		count += 10 * i
		if length == 1:
			count += 1
		elif length == 2:
			count += 3
		elif length == 3:
			count += 6
		elif length == 4:
			count += 10
	elif length == 1:
		count += 1
	elif length == 2:
		count += 3
	elif length == 3:
		count += 6
	elif length == 4:
		count += 10
	print(count)


for _ in range(int(input())):
	n = int(input())
	s = str(n)
	(c, s1, d) = (len(s), 0, n % 10)
	while c != 0:
		s1 += c
		c -= 1
	ans = 10 * (d - 1) + s1
	print(ans)


for _ in range(int(input())):
	n = input()
	l = [1, 2, 3, 4]
	L = []
	for j in range(0, 9):
		L.append(l)
	k = len(n)
	for m in range(1, 10):
		if n[0] == str(m):
			break
	s = 0
	for j in range(1, 10):
		if j == m:
			s += sum(L[j - 1][:k])
			break
		else:
			s += sum(L[j - 1])
	print(s)


t = int(input())
for i in range(t):
	x = str(input())
	ans = 0
	lenn = len(x)
	dig = int(x[0])
	if lenn == 1:
		ans = 10 * (dig - 1) + lenn
	elif lenn == 2:
		ans = 10 * (dig - 1) + lenn + 1
	elif lenn == 3:
		ans = 10 * (dig - 1) + lenn + 3
	elif lenn == 4:
		ans = 10 * (dig - 1) + lenn + 6
	print(ans)


import math
t = int(input())
for _ in range(t):
	s = input()
	ans = (int(s[0]) - 1) * 10
	ans += len(s) * (len(s) + 1) // 2
	print(ans)


import sys
import math

def II():
	return int(sys.stdin.readline())

def LI():
	return list(map(int, sys.stdin.readline().split()))

def MI():
	return map(int, sys.stdin.readline().split())

def SI():
	return sys.stdin.readline().strip()
t = II()
for q in range(t):
	x = II()
	ans = 0
	boo = True
	for i in range(1, 10):
		for j in range(1, 10000):
			if len(set(str(j))) == 1 and str(i) in str(j):
				ans += len(str(j))
				if j == x:
					boo = False
					break
		if boo == False:
			break
	print(ans)


test_cases = int(input())
for test_case in range(test_cases):
	n = input()
	ans = 10 * (int(n[0]) - 1)
	x = len(n)
	if x == 1:
		ans += 1
	elif x == 2:
		ans += 3
	elif x == 3:
		ans += 6
	elif x == 4:
		ans += 10
	print(ans)


for _ in range(int(input())):
	n = int(input())
	k = n % 10
	p = len(str(n))
	if p == 1:
		t = 1
	if p == 2:
		t = 3
	if p == 3:
		t = 6
	if p == 4:
		t = 10
	print((k - 1) * 10 + t)


t = int(input())
l = []
for i in range(t):
	n = input()
	count = 0
	if n == '1' and len(n) == 1:
		l.append(n)
	else:
		if len(n) == 1:
			count = (int(n) - 1) * 10 + 1
		elif len(n) == 2:
			count = (int(n[0]) - 1) * 10 + 3
		elif len(n) == 3:
			count = (int(n[0]) - 1) * 10 + 6
		elif len(n) == 4:
			count = (int(n[0]) - 1) * 10 + 10
		l.append(count)
for i in l:
	print(i)


t = int(input())
for i in range(t):
	x = int(input())
	y = 1
	stry = '1'
	colvo = 1
	if len(str(x)) == 4:
		colvo = 10 * int(str(x)[0])
	else:
		while stry != str(x):
			stry += str(y)
			colvo += len(stry)
			if len(stry) == 4:
				y += 1
				stry = ''
	print(colvo)


import sys
import math
from collections import defaultdict, deque
input = sys.stdin.readline

def inar():
	return [int(el) for el in input().split()]

def main():
	t = int(input())
	for _ in range(t):
		ans = [1, 3, 6, 10]
		n = int(input())
		n = str(n)
		take = 0
		take = (int(n[0]) - 1) * 10
		lol = len(n)
		take += ans[lol - 1]
		print(take)
main()


t = int(input())
for i in range(t):
	n1 = input()
	n2 = len(n1)
	r = int(n1[0])
	ans = (r - 1) * 10
	if n2 == 1:
		ans += 1
		print(ans)
	elif n2 == 2:
		ans += 3
		print(ans)
	elif n2 == 3:
		ans += 6
		print(ans)
	elif n2 == 4:
		ans += 10
		print(ans)


round = int(input())
for _ in range(round):
	test = int(input())
	if test < 10:
		print(10 * (test - 1) + 1)
	if 10 < test < 100:
		mod = test // 10
		print(10 * (mod - 1) + 3)
	if 100 < test < 1000:
		mod = test // 100
		print(10 * (mod - 1) + 6)
	if 1000 < test < 10000:
		mod = test // 1000
		print(10 * mod)


t = int(input())
for i in range(t):
	x = int(input())
	s = str(x)
	n = len(s)
	m = int(s[0])
	digit = (m - 1) * 10
	if n == 1:
		result = digit + 1
	elif n == 2:
		result = digit + 3
	elif n == 3:
		result = digit + 6
	else:
		result = digit + 10
	print(result)


t = int(input())
l = []
for i in range(1, 10):
	for j in range(1, 5):
		num = int(''.join([str(i)] * j))
		l.append([num, j])
for ti in range(t):
	n = int(input())
	ans = 0
	for (x, y) in l:
		ans += y
		if x == n:
			print(ans)
			break


t = int(input())
while t:
	x = int(input())
	y = ''.join(set(str(x)))
	z = str(x)
	r = 10 * (int(y) - 1)
	if len(z) == 1:
		r = r + 1
	elif len(z) == 2:
		r = r + 3
	elif len(z) == 3:
		r = r + 6
	else:
		r = r + 10
	print(r)
	t -= 1


import os
import sys
from io import BytesIO, IOBase
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
input = lambda : sys.stdin.readline().rstrip('\r\n')
readint = lambda : int(sys.stdin.readline().rstrip('\r\n'))
readints = lambda : map(int, sys.stdin.readline().rstrip('\r\n').split())
readstr = lambda : sys.stdin.readline().rstrip('\r\n')
readstrs = lambda : map(str, sys.stdin.readline().rstrip('\r\n').split())
readarri = lambda : [int(_) for _ in sys.stdin.readline().rstrip('\r\n').split()]
readarrs = lambda : [str(_) for _ in sys.stdin.readline().rstrip('\r\n').split()]

def main():
	for _ in range(int(input())):
		x = readint()
		lx = len(str(x))
		if lx == 4:
			print(x % 10 * 10)
		else:
			print((x % 10 - 1) * 10 + lx * (lx + 1) // 2)
main()


T = int(input())
for _ in range(T):
	lst = [1, 3, 6, 10]
	n = int(input())
	which = n % 10
	ln = len(str(n))
	temp = (which - 1) * 10
	x = lst[ln - 1]
	print(temp + x)


def po(a):
	s = 0
	for ele in c:
		s = s + len(ele)
		if ele == a:
			return s
c = []
for i in range(1, 10):
	for j in range(1, 5):
		c.append(str(i) * j)
t = int(input())
for _ in range(0, t):
	a = input()
	print(po(a))


t = int(input())
inputs = []
while True:
	if len(inputs) == t:
		break
	x = input()
	inputs.append(int(x))
for i in inputs:
	sum1 = 0
	if i < 10:
		if i % 10 == 1:
			sum1 = 1
			print(sum1)
		else:
			sum1 = 10 * (i % 10 - 1) + 1
			print(sum1)
	elif 10 < i < 100:
		if i % 10 == 1:
			sum1 = 3
			print(sum1)
		else:
			sum1 = 10 * (i % 10 - 1) + 3
			print(sum1)
	elif 100 < i < 1000:
		if i % 10 == 1:
			sum1 = 6
			print(sum1)
		else:
			sum1 = 10 * (i % 10 - 1) + 6
			print(sum1)
	elif 1000 < i < 10000:
		if i % 10 == 1:
			sum1 = 10
			print(sum1)
		else:
			sum1 = 10 * (i % 10)
			print(sum1)


def cal(n):
	start = int(str(n)[0])
	cur = (start - 1) * 10
	index = 1
	cur_start = start
	while index <= 4 and cur_start <= n:
		index += 1
		cur += len(str(cur_start))
		cur_start = int(str(start) * index)
	return cur
t = int(input())
for _ in range(t):
	n = int(input())
	print(cal(n))


val = []
num = []
for i in range(1, 10):
	for j in range(1, 5):
		val.append(str(i) * j)
		if len(num):
			num.append(num[len(num) - 1] + j)
		else:
			num.append(1)
n = int(input())
for i in range(n):
	d = input()
	print(num[val.index(d)])


def find():
	n = input()
	ans = 10 * (int(n[0]) - 1)
	for i in range(1, len(n) + 1):
		ans += i
	print(ans)
t = int(input())
while t > 0:
	find()
	t -= 1


from collections import *
import sys
input = sys.stdin.readline

def ri():
	return int(input())

def rl():
	return list(map(int, input().split()))
t = ri()
for _ in range(t):
	x = ri()
	ans = 0
	stop = False
	for i in range(1, 10):
		if stop == True:
			break
		for j in range(1, 5):
			current = ''.join([str(i)] * j)
			current = int(current)
			ans += j
			if current == x:
				stop = True
				break
	print(ans)


t = int(input())
for _ in range(t):
	n = int(input())
	x = n
	c = 0
	while n > 0:
		c += 1
		n = n // 10
	y = x // pow(10, c - 1)
	if c == 1:
		print((y - 1) * 10 + 1)
	elif c == 2:
		print((y - 1) * 10 + 3)
	elif c == 3:
		print((y - 1) * 10 + 6)
	else:
		print((y - 1) * 10 + 10)


k = 0
n = int(input())
for i in range(n):
	s = input()
	k += (int(s) % 10 - 1) * 10
	for j in range(1, len(s) + 1):
		k += j
	print(k)
	k = 0


def solve():
	s = input()
	n = int(s)
	d = n % 10
	t = len(s)
	nd = 0
	while t > 0:
		nd += t
		t -= 1
	print((d - 1) * 10 + nd)
t = int(input())
for _ in range(t):
	solve()


import sys
LI = lambda : list(map(int, sys.stdin.readline().strip('\n').split()))
MI = lambda : map(int, sys.stdin.readline().strip('\n').split())
SI = lambda : sys.stdin.readline().strip('\n')
II = lambda : int(sys.stdin.readline().strip('\n'))
num = [0, 1, 3, 6, 10]
for _ in range(II()):
	x = SI()
	print(10 * (int(x[0]) - 1) + num[len(x)])


t = int(input())
for i in range(t):
	x = int(input())
	s = (x % 10 - 1) * 10
	p = str(x)
	q = len(p)
	print(int(s + q * (q + 1) / 2))


t = int(input())
while t:
	t -= 1
	n = input()
	l = len(n)
	d = int(n[0])
	ans = 0
	for i in range(d - 1):
		ans += 10
	for i in range(l + 1):
		ans += i
	print(ans)


t = int(input())
for _ in range(t):
	ans = 0
	n = int(input())
	length = len(str(n))
	if length == 1:
		ans += 1
	elif length == 2:
		ans += 3
	elif length == 3:
		ans += 6
	else:
		ans += 10
	neco = int(str(n)[0]) - 1
	ans += neco * 10
	print(ans)


for _ in range(int(input())):
	x = input()
	count = 0
	for i in range(int(x[0]) - 1):
		for j in range(4):
			count += j + 1
	for i in range(len(x)):
		count += i + 1
	print(count)


t = int(input())
for q in range(0, t):
	n = int(input())
	curr = 1
	track = 1
	ans = 0
	count = 0
	while True:
		s = str(curr)
		count += 1
		if int(s) == n:
			break
		s += str(track)
		curr = int(s)
		if count == 4:
			track += 1
			curr = track
			ans += count * (count + 1) // 2
			count = 0
	if count != 0:
		ans += count * (count + 1) // 2
	print(ans)


t = int(input())
one = 1
two = 3
three = 6
four = 10
for i in range(t):
	case = input()
	if len(case) == 4:
		ans = int(case[0]) * four
	elif len(case) == 3:
		ans = (int(case[0]) - 1) * four + three
	elif len(case) == 2:
		ans = (int(case[0]) - 1) * four + two
	else:
		ans = (int(case[0]) - 1) * four + one
	print(ans)


from collections import Counter
from collections import OrderedDict
from collections import defaultdict
import bisect

def freq_count(mylist):
	return Counter(mylist)
t = int(input())
for _ in range(t):
	n = input()
	l = len(n)
	num = int(n[0])
	sum1 = l * (l + 1) // 2
	for i in range(1, num):
		sum1 += 10
	print(sum1)


for _ in range(int(input())):
	n = int(input())
	k = []
	for i in range(1, 10):
		k += [i, i + i * 10, i + i * 10 + i * 100, i + i * 10 + i * 100 + i * 1000]
	c = 0
	for i in range(len(k)):
		if k[i] == n:
			c += len(str(k[i]))
			break
		c += len(str(k[i]))
	print(c)


import os
from heapq import heapify, heappop, heappush
import sys
import math
import operator
import bisect
from collections import defaultdict
from io import BytesIO, IOBase
sys.setrecursionlimit(10 ** 5)

def inpt():
	return [int(k) for k in input().split()]

def main():
	for _ in range(int(input())):
		n = int(input())
		ans = 0
		n = str(n)
		prev = int(n[0]) - 1
		ans += prev * 10
		if len(n) == 1:
			ans += 1
		elif len(n) == 2:
			ans += 3
		elif len(n) == 3:
			ans += 6
		else:
			ans += 10
		print(ans)
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
input = lambda : sys.stdin.readline().rstrip('\r\n')
main()


a = [1, 11, 111, 1111, 2, 22, 222, 2222, 3, 33, 333, 3333, 4, 44, 444, 4444, 5, 55, 555, 5555, 6, 66, 666, 6666, 7, 77, 777, 7777, 8, 88, 888, 8888, 9, 99, 999, 9999]
b = [1, 2, 3, 4, 1, 2, 3, 4, 1, 2, 3, 4, 1, 2, 3, 4, 1, 2, 3, 4, 1, 2, 3, 4, 1, 2, 3, 4, 1, 2, 3, 4, 1, 2, 3, 4]
query = int(input())
while query > 0:
	x = int(input())
	key = a.index(x)
	ans = sum(b[0:key + 1])
	print(ans)
	query -= 1


import sys
from math import sqrt
from collections import defaultdict
inpt = sys.stdin.readline

def inp():
	return int(inpt())

def inlist():
	return list(map(int, inpt().split()))

def instr():
	s = inpt()
	return list(s[:len(s) - 1])

def inbitstr():
	s = inpt()
	return [int(i) for i in list(s[:len(s) - 1])]

def invr():
	return map(int, inpt().split())

def printlist(a):
	for i in range(len(a)):
		print(a[i], end='')
	print()

class Graph:

	def __init__(self, n):
		self.n = n
		self.graph = defaultdict(list)
		self.marked = defaultdict(int)
		self.wt = defaultdict(int)

	def addEdge(self, u, v, wt):
		self.graph[u].append(v)
		self.graph[v].append(u)
		self.wt[n * u + v] = wt

	def cleanup(self):
		self.marked = defaultdict(int)

	def dfs(self, u):
		self.marked[u] = 1
		(max, maxnode) = (0, u)
		for i in self.graph[u]:
			(cur, node) = (0, 0)
			if self.marked[i] == 0:
				(cur, node) = self.dfs(i)
			if cur > max:
				max = cur
				maxnode = node
		return (1 + max, maxnode)

	def lngdfs(self, u, v):
		self.marked[u] = 1
		max = self.n
		for i in self.graph[u]:
			if i == v:
				return 1
			cur = self.n
			if self.marked[i] == 0:
				cur = self.lngdfs(i, v)
			if cur < max:
				max = cur
		return 1 + max

def main():
	t = inp()
	for l in range(t):
		n = inp()
		ln = len(str(n))
		num = n % 10
		ans = 10 * (num - 1)
		for i in range(1, ln + 1):
			ans += i
		print(ans)
main()


from sys import stdin
input = stdin.readline
for _ in range(int(input())):
	s = input()
	n = int(s[0])
	t = (n - 1) * 10
	l = len(s)
	t += (l - 1) * l // 2
	print(t)


for _ in range(int(input())):
	n = int(input())
	k = str(n)
	m = len(k)
	lst = [1, 3, 6, 10]
	print((int(k[0]) - 1) * 10 + lst[m - 1])


def generate(n):
	res = 0
	for i in range(1, (int(str(n)[0]) - 1) * 4 + len(str(n)) + 1):
		if i % 4 == 0:
			res += 4
		else:
			res += i % 4
	return res
n = int(input())
for _ in range(n):
	k = int(input())
	print(generate(k))


for _ in range(int(input())):
	s = input()
	k = (int(s[0]) - 1) * 10
	z = len(s)
	z = z * (z + 1) // 2
	print(k + z)


tt = int(input())
for t in range(tt):
	n = input()
	s = (int(n[0]) - 1) * 10
	if len(n) == 1:
		s += 1
	elif len(n) == 2:
		s += 3
	elif len(n) == 3:
		s += 6
	elif len(n) == 4:
		s += 10
	print(s)


a = ['1', '11', '111', '1111', '2', '22', '222', '2222', '3', '33', '333', '3333', '4', '44', '444', '4444', '5', '55', '555', '5555', '6', '66', '666', '6666', '7', '77', '777', '7777', '8', '88', '888', '8888', '9', '99', '999', '9999']
t = int(input())
while t:
	n = int(input())
	i = 0
	count = 0
	while int(a[i]) != n:
		count += len(a[i])
		i += 1
	print(count + len(str(n)))
	t -= 1


for _ in range(int(input())):
	n = str(input())
	l = len(n)
	y = int(n[0])
	x = l * (l + 1) // 2
	res = 10 * (y - 1) + x
	print(res)


for _ in range(int(input())):
	n = input()
	k = n[0]
	s = len(n)
	n = int(n)
	tot = 0
	tot += s * (s + 1) // 2 + 10 * (int(k) - 1)
	print(tot)


import sys
input = sys.stdin.readline
t = int(input())
all_nums = []
prefix = []
for i in range(1, 10):
	for j in range(1, 5):
		all_nums.append(str(i) * j)
		if prefix:
			prefix.append(prefix[-1] + j)
		else:
			prefix.append(j)
all_nums.sort()
for _ in range(t):
	x = input().rstrip()
	print(prefix[all_nums.index(x)])


tests = int(input())
for _ in range(tests):
	s = input()
	res = (int(s[0]) - 1) * 10
	k = [0, 1, 3, 6, 10]
	res += k[len(s)]
	print(res)


import sys, math, itertools
from collections import Counter, deque, defaultdict
from bisect import bisect_left, bisect_right
mod = 10 ** 9 + 7
INF = float('inf')

def inp():
	return int(sys.stdin.readline())

def inpl():
	return list(map(int, sys.stdin.readline().split()))
for _ in range(inp()):
	x = inp()
	x = str(x)
	res = 0
	for i in range(1, 10):
		for j in range(1, 5):
			res += j
			if x == str(i) * j:
				print(res)


t = int(input())
for i in range(t):
	res = 0
	n = input()
	for j in range(1, int(n[0]) + 1):
		for k in range(4):
			res += k + 1
			if str(j) * (k + 1) == n:
				break
	print(res)


w = int(input())
for i in range(w):
	s = input()
	ln = len(s)
	h = int(s[0]) - 1
	print(h * 10 + ln * (ln + 1) // 2)


t = int(input())
answer = []
for i in range(t):
	x = int(input())
	n = 0
	flag = True
	count = 0
	while n < 10 and flag:
		n += 1
		j = 1
		s = ''
		while j < 5 and flag:
			s += str(n)
			count += j
			if int(s) == x:
				flag = False
			j += 1
	answer.append(count)
for a in answer:
	print(a)


t = int(input())
while t > 0:
	n = int(input())
	if n < 10:
		div = n - 1
		print(div * 10 + 1)
		t -= 1
		continue
	elif n > 10 and n < 100:
		div = n // 11 - 1
		print(div * 10 + 3)
		t -= 1
		continue
	elif n > 100 and n < 1000:
		div = n // 111 - 1
		print(div * 10 + 6)
		t -= 1
		continue
	elif n > 1000 and n < 10000:
		div = n // 1111 - 1
		print(div * 10 + 10)
		t -= 1
		continue


t = int(input())
finalans = []
for _ in range(t):
	n = input()
	list1 = [1, 11, 111, 1111]
	list2 = [2, 22, 222, 2222]
	list3 = [3, 33, 333, 3333]
	list4 = [4, 44, 444, 4444]
	list5 = [5, 55, 555, 5555]
	list6 = [6, 66, 666, 6666]
	list7 = [7, 77, 777, 7777]
	list8 = [8, 88, 888, 8888]
	list9 = [9, 99, 999, 9999]
	ans = []

	def countDigit(n):
		count = 0
		while n != 0:
			n //= 10
			count += 1
		return count
	if n[0] == '1':
		for i in list1:
			if i <= int(n):
				ans.append(i)
	if n[0] == '2':
		ans += list1
		for i in list2:
			if i <= int(n):
				ans.append(i)
	if n[0] == '3':
		ans += list1 + list2
		for i in list3:
			if i <= int(n):
				ans.append(i)
	if n[0] == '4':
		ans += list1 + list2 + list3
		for i in list4:
			if i <= int(n):
				ans.append(i)
	if n[0] == '5':
		ans += list1 + list2 + list3 + list4
		for i in list5:
			if i <= int(n):
				ans.append(i)
	if n[0] == '6':
		ans += list1 + list2 + list3 + list4 + list5
		for i in list6:
			if i <= int(n):
				ans.append(i)
	if n[0] == '7':
		ans += list1 + list2 + list3 + list4 + list5 + list6
		for i in list7:
			if i <= int(n):
				ans.append(i)
	if n[0] == '8':
		ans += list1 + list2 + list3 + list4 + list5 + list6 + list7
		for i in list8:
			if i <= int(n):
				ans.append(i)
	if n[0] == '9':
		ans += list1 + list2 + list3 + list4 + list5 + list6 + list7 + list8
		for i in list9:
			if i <= int(n):
				ans.append(i)
	counterans = 0
	for i in ans:
		counterans += countDigit(i)
	finalans.append(counterans)
for i in finalans:
	print(i)


import math
a = []
for i in range(1, 10):
	cur = i
	while math.log10(cur) + 1 < 5:
		a.append(cur)
		cur = cur * 10 + i
t = int(input())
for _ in range(t):
	n = int(input())
	ans = 0
	for i in a:
		ans += int(math.log10(i) + 1)
		if i == n:
			break
	print(ans)


import math
from decimal import *
import random
for _ in range(int(input())):
	x = int(input())
	n = len(str(x))
	print(10 * (int(str(x)[0]) - 1) + (n + 1) * n // 2)


t = int(input())
for i in range(t):
	k = int(input())
	ans = 0
	for l in range(1, 10):
		if str(k)[0] == str(l)[0]:
			val = l
			for m in range(4):
				if k >= val:
					ans += m + 1
				else:
					break
				val = val * 10 + l
			break
		else:
			ans += 10
	print(ans)


for i in range(int(input())):
	n = int(input())
	s = n % 10
	l = len(str(n))
	x = l * (l + 1) // 2
	c = (s - 1) * 10
	print(x + c)


l = []
for x in range(1, 10):
	s = ''
	for y in range(4):
		s += str(x)
		l.append(s)
t = int(input())
for x in range(t):
	n = input()
	index = 0
	ans = 0
	while l[index] != n:
		ans += len(l[index])
		index += 1
	print(ans + len(n))


t = int(input())
for i in range(0, t):
	str1 = input()
	x = int(str1[0])
	y = x - 1
	bef = y * 10
	z = len(str1)
	if z == 1:
		ans = bef + 1
	elif z == 2:
		ans = bef + 3
	elif z == 3:
		ans = bef + 6
	elif z == 4:
		ans = bef + 10
	print(ans)


t = int(input())
for _ in range(t):
	s = input()
	temp = s[0]
	n = len(s)
	mu = int(temp) - 1
	res = mu * 10 + n * (n + 1) / 2
	print(int(res))


M = 4
t = int(input())
for it in range(t):
	x = input()
	d = int(x) % 10
	p = (d - 1) * M * (M + 1) // 2
	p += len(x) * (len(x) + 1) // 2
	print(p)


from math import *
from cmath import *
from itertools import *
from decimal import *
from fractions import *
from sys import *
for _ in range(int(input())):
	s = input()
	ans = 0
	for x in range(len(s)):
		ans += x + 1
	print(ans + (ord(s[0]) - ord('1')) * 10)


import math
for _ in range(int(input())):
	a = int(input())
	x = a % 10
	y = math.log(a, 10) + 1
	y = int(y)
	print((x - 1) * 10 + y * (y + 1) // 2)


def answer():
	n = input()
	a = int(n[0])
	ans = 10 * (a - 1)
	ans += len(n) * (len(n) + 1) / 2
	print(int(ans))
t = int(input())
for i in range(t):
	answer()


class Case:

	def __init__(self, n):
		self.n = n

	def solution(self):
		number_of_digits = len(self.n)
		digit = int(self.n[0])
		return (digit - 1) * 10 + number_of_digits * (number_of_digits + 1) // 2
T = int(input())
for t in range(1, T + 1):
	n = input()
	case = Case(n)
	print('{}'.format(case.solution()))


for _ in range(int(input())):
	n = input()
	x = (int(n[0]) - 1) * 10
	if len(n) == 4:
		print(x + 10)
		continue
	if len(n) == 3:
		print(x + 6)
		continue
	if len(n) == 2:
		print(x + 3)
		continue
	if len(n) == 1:
		print(x + 1)
		continue


import sys
input = sys.stdin.readline
t = int(input())
for _ in range(t):
	n = input()[:-1]
	if len(n) == 1:
		k = 1
	elif len(n) == 2:
		k = 3
	elif len(n) == 3:
		k = 6
	else:
		k = 10
	print((int(n[0]) - 1) * 10 + k)


MOD = 1000000007
ii = lambda : int(input())
si = lambda : input()
dgl = lambda : list(map(int, input()))
f = lambda : map(int, input().split())
il = lambda : list(map(int, input().split()))
ls = lambda : list(input())
from collections import *
for _ in range(ii()):
	n = si()
	l = int(n[0]) - 1
	p = len(n)
	print(l * 10 + p * (p + 1) // 2)


T = int(input())
fixed = [1, 3, 6, 10]
for t in range(T):
	x = input()
	x_len = len(x)
	x_char = x[0]
	print(10 * (int(x_char) - 1) + fixed[x_len - 1])


def summ(s):
	res = 0
	for i in s:
		res += int(i)
	return res
for _ in range(int(input())):
	n = int(input())
	ans = []
	for i in range(1, 10):
		ans.append(str(i))
		ans.append(str(i) * 2)
		ans.append(str(i) * 3)
		ans.append(str(i) * 4)
	i = 0
	xs = 0
	while n != int(ans[i]):
		xs += len(ans[i])
		i += 1
	xs += len(ans[i])
	i += 1
	print(xs)


n = int(input())
l = []
for i in range(n):
	x = int(input())
	l.append(x)
for i in range(n):
	n1 = len(str(l[i]))
	n2 = int(l[i] / 10 ** (n1 - 1)) - 1
	y = 10 * n2
	for j in range(1, n1 + 1):
		y += j
	print(y)


t = int(input())
for i in range(0, t):
	x = input()
	ln = len(x)
	d = int(x[0])
	ans = 10 * (d - 1) + ln * (ln + 1) // 2
	print(ans)


for _ in range(int(input())):
	n = int(input())
	a = [1, 11, 111, 1111]
	(a0, a1, a2, a3) = (1, 11, 111, 1111)
	count = 0
	if n in a:
		for i in a:
			if i != n:
				count = count + len(str(i))
			else:
				count = count + len(str(i))
				break
	else:
		while n not in a:
			for i in range(len(a)):
				if i == 0:
					a[i] = a[i] + a0
				elif i == 1:
					a[i] = a[i] + a1
				elif i == 2:
					a[i] = a[i] + a2
				elif i == 3:
					a[i] = a[i] + a3
			if n in a:
				count = 10 * (a[0] - 1)
				for i in a:
					if i != n:
						count = count + len(str(i))
					else:
						count = count + len(str(i))
						break
	print(count)


import sys
import math
from collections import defaultdict, Counter
input = sys.stdin.readline

def print(x):
	sys.stdout.write(str(x) + '\n')
t = int(input())
for i in range(t):
	x = int(input())
	d = (x % 10 - 1) * 10
	s = len(str(x))
	ans = d + s * (s + 1) // 2
	print(ans)


for _ in range(int(input())):
	x = int(input())
	n = x
	ans = 0
	ans += n % 10 * 10
	if x >= 1 and x <= 9:
		ans -= 9
	elif x >= 10 and x <= 99:
		ans -= 7
	elif x >= 100 and x <= 999:
		ans -= 4
	print(ans)


for _ in range(int(input())):
	x = input()
	w = int(x[0])
	sum = (w - 1) * 10
	i = 1
	out = str(w)
	sum += 1
	while out != x:
		i += 1
		sum += i
		out = str(w) * i
	print(sum)


t = int(input())
while t > 0:
	s = input()
	a = int(s[0])
	ans = 10 * (a - 1)
	n = len(s)
	if len(s) == 1:
		ans = ans + 1
	elif len(s) == 2:
		ans = ans + 3
	elif len(s) == 3:
		ans = ans + 6
	else:
		ans = ans + 10
	print(ans)
	t = t - 1


def summan(n):
	count = 0
	while n > 0:
		count += len(str(n))
		n //= 10
	return count
n = int(input())
for i in range(n):
	a = int(input())
	print((a % 10 - 1) * 10 + summan(a))


t = int(input())
l = []
for i in range(1, 10):
	s = ''
	for j in range(4):
		s = s + str(i)
		l.append(s)
d = {}
for i in range(len(l)):
	d[l[i]] = i
dp = [0 for i in range(len(l))]
dp[0] = 1
for i in range(1, len(l)):
	dp[i] = dp[i - 1] + len(l[i])
for i in range(t):
	s = input()
	print(dp[d[s]])


t = int(input())
for i in range(t):
	x = int(input())
	xlen = int(len(str(x)))
	xmitmes = int(str(x)[0])
	var = (xmitmes - 1) * 10 + max(xlen, 0) + max(xlen - 1, 0) + max(xlen - 2, 0) + max(xlen - 3, 0)
	print(var)


def inp():
	return int(input())

def inl():
	return [int(i) for i in input().split()]
p = inp()
for _ in range(p):
	x = input()
	l = int(x[0])
	l1 = len(x)
	l = (l - 1) * 10
	for i in range(1, l1 + 1):
		l += i
	print(l)


inp1 = int(input())
for i in range(inp1):
	inp2 = input()
	dig = int(inp2[0]) - 1
	print(dig * 10 + len(inp2) * (len(inp2) + 1) // 2)


for _ in range(int(input())):
	lim = input()
	loop = int(lim[0])
	length = len(lim)
	ans = 0
	j = 0
	for i in range(loop):
		if i == loop - 1:
			for j in range(length):
				ans += j + 1
		else:
			for j in range(4):
				ans += j + 1
	print(ans)


def get_dict_key(val):
	for (key, value) in my_dict.items():
		if val == value:
			return key
for _ in range(int(input())):
	dictionary = {'1': 1, '11': 3, '111': 6, '1111': 10, '2': 11, '22': 13, '222': 16, '2222': 20, '3': 21, '33': 23, '333': 26, '3333': 30, '4': 31, '44': 33, '444': 36, '4444': 40, '5': 41, '55': 43, '555': 46, '5555': 50, '6': 51, '66': 53, '666': 56, '6666': 60, '7': 61, '77': 63, '777': 66, '7777': 70, '8': 71, '88': 73, '888': 76, '8888': 80, '9': 81, '99': 83, '999': 86, '9999': 90}
	my_dict = {y: x for (x, y) in dictionary.items()}
	x = input()
	print(get_dict_key(x))


from math import gcd
from itertools import combinations, permutations, accumulate, product
from collections import deque, defaultdict, Counter
import decimal
import re
import math
import bisect
import heapq
import sys
sys.setrecursionlimit(10000000)
mod = 10 ** 9 + 7
INF = float('inf')
dx = [-1, 0, 0, 1]
dy = [0, 1, -1, 0]
from sys import stdin
readline = stdin.readline

def readInts():
	return list(map(int, readline().split()))

def readTuples():
	return tuple(map(int, readline().split()))

def I():
	return int(readline())
ans = []
for i in range(1, 10):
	s = ''
	s += str(i)
	ans.append(s)
	for j in range(3):
		s += str(i)
		ans.append(s)
q = I()
for _ in range(q):
	s = input()
	a = 0
	for i in range(len(ans)):
		a += len(ans[i])
		if s == ans[i]:
			print(a)
			break


casos = int(input())
resps = []
for i in range(casos):
	num = input()
	tabela = {1: 1, 2: 3, 3: 6, 4: 10}
	resps.append((int(num[0]) - 1) * 10 + tabela[len(num)])
print(*resps, sep='\n')


t = int(input())
for _ in range(t):
	x = int(input())
	a = str(x)
	b = x % 10
	c = (b - 1) * 10
	d = len(a)
	e = 1
	while e <= d:
		c += e
		e += 1
	print(c)


for q in range(int(input())):
	x = input()
	res = 0
	f = 0
	for i in range(1, 10):
		for j in range(1, 5):
			res += len(str(i) * j)
			if str(i) * j == x:
				f = 1
				break
		if f != 0:
			break
	print(res)


t = int(input())
flats = []
for i in range(1, 10):
	for q in range(1, 5):
		string = str(i) * q
		flats.append(string)
output = []
for q in range(t):
	x = input()
	output.append(len(''.join(flats[0:flats.index(x) + 1])))
for i in range(len(output)):
	print(output[i])


import sys

def rl():
	return sys.stdin.readline().strip()

def pr(something):
	sys.stdout.write(str(something) + '\n')

def pra(array):
	sys.stdout.write(' '.join([str(x) for x in array]) + '\n')

def solve(array):
	return array
NT = int(rl())
accum = 0
cum_dig = {}
for i in range(1, 10):
	for d in range(1, 5):
		ii = int(str(i) * d)
		accum += d
		cum_dig[ii] = accum
for ti in range(NT):
	val = int(rl())
	pr(cum_dig[val])


t = int(input())
for _ in range(t):
	x = input()
	res = (int(x[0]) - 1) * 10 + sum(range(1, len(x) + 1))
	print(res)


import sys
import math
import bisect
from sys import stdin, stdout
from math import gcd, floor, sqrt, log
from collections import defaultdict as dd
from bisect import bisect_left as bl, bisect_right as br
sys.setrecursionlimit(100000000)
ii = lambda : int(input())
si = lambda : input()
jn = lambda x, l: x.join(map(str, l))
sl = lambda : list(map(str, input().strip()))
mi = lambda : map(int, input().split())
mif = lambda : map(float, input().split())
lii = lambda : list(map(int, input().split()))
ceil = lambda x: int(x) if x == int(x) else int(x) + 1
ceildiv = lambda x, d: x // d if x % d == 0 else x // d + 1
flush = lambda : stdout.flush()
stdstr = lambda : stdin.readline()
stdint = lambda : int(stdin.readline())
stdpr = lambda x: stdout.write(str(x))
mod = 1000000007
for _ in range(ii()):
	s = si()
	n = len(s)
	ans = (int(s) % 10 - 1) * 10
	ans += n * (n + 1) // 2
	print(ans)


def solve():
	x = input()
	c = 0
	for i in range(1, 10):
		j = 1
		while int(str(i) * j) < 10000:
			c += j
			if str(i) * j == x:
				return c
			j += 1
t = int(input())
i = 0
while i < t:
	print(solve())
	i += 1


for _ in range(int(input())):
	answer = 0
	N = input()
	init = N[0]
	answer += (int(init) - 1) * 10
	tmp = init
	while N != tmp:
		tmp += init
		answer += len(tmp)
	print(answer + 1)


d = {}
c = 0
for i in range(1, 10):
	for j in range(1, 5):
		c += j
		d[str(i) * j] = c
t = int(input())
for i in range(t):
	a = input()
	print(d[str(a)])


def read_int() -> int:
	return int(input())

def read_ints():
	return map(int, input().split(' '))

def nums():
	for ch in map(str, range(1, 10)):
		for i in range(1, 5):
			yield int(ch * i)

def test_case():
	x = read_int()
	counter = 0
	for num in nums():
		counter += len(str(num))
		if num == x:
			break
	print(counter)
for _ in range(read_int()):
	test_case()


n = int(input())
for i in range(0, n):
	boring = input()
	y = int(boring[0])
	s = len(boring)
	x = int(boring)
	tot = 1
	for i in range(0, y):
		if i == y - 1:
			for k in range(1, s):
				tot = tot + k + 1
			break
		tot = tot + 10
	print(tot)


try:
	t = int(input())
	for _ in range(t):
		n = int(input())
		dig = len(str(n))
		num = n % 10
		l = [1, 2, 3, 4]
		ans = sum(l) * (num - 1)
		ans += sum(l[:dig])
		print(ans)
except:
	pass


t = int(input())
digitarray = [0, 1, 3, 6, 10]
while t:
	t -= 1
	x = input()
	s = (int(x[0]) - 1) * 10
	s += digitarray[len(x)]
	print(s)


t = int(input())
for i in range(t):
	x = int(input())
	y = str(x)
	l = []
	for i in range(1, len(str(x)) + 1):
		l.append(i)
	print((int(y[0]) - 1) * 10 + sum(l))


t = int(input())
arr = []
for i in range(t):
	arr.append(int(input()))
for i in arr:
	if i == 1:
		print(1)
	else:
		n = 1
		x = 1
		c = 1
		m = 1
		while n != i:
			n += m * 10 ** x
			x += 1
			c += x
			if n != i and x == 4:
				x = 1
				c += 1
				m += 1
				n = m
		print(c)


for tt in range(int(input())):
	n = int(input())
	n1 = str(n)
	print(10 * (int(n1[0]) - 1) + len(n1) * (len(n1) + 1) // 2)


for _ in range(int(input())):
	x = int(input())
	a = x % 10
	ans = 10 * (a - 1)
	cnt = 0
	for i in [1, 11, 111, 1111]:
		cnt += 1
		if x <= i * a:
			break
	ans += cnt * (cnt + 1) // 2
	print(ans)


def thuatToanConTran(n):
	(x, n, res) = (int(str(n)[0]), len(str(n)), 0)
	res = (x - 1) * 10
	for i in range(1, n + 1):
		res += i
	return res
n = int(input())
for _ in range(n):
	k = int(input())
	print(thuatToanConTran(k))


for t in range(int(input())):
	x = input()
	ans = 0
	for i in range(1, 10):
		if str(i) <= x:
			ans += 1
			if str(i) == x:
				break
		if str(10 * i + i) <= x:
			ans += 2
			if str(10 * i + i) == x:
				break
		if str(100 * i + 10 * i + i) <= x:
			ans += 3
			if str(100 * i * 10 * i + i) == x:
				break
		if str(1000 * i + 100 * i + 10 * i + i) <= x:
			ans += 4
			if str(1000 * i + 100 * i * 10 * i + i) == x:
				break
	print(ans)


import os
import sys
from io import BytesIO, IOBase
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
input = lambda : sys.stdin.readline().rstrip('\r\n')

def RL():
	return map(int, sys.stdin.readline().rstrip().split())

def RLL():
	return list(map(int, sys.stdin.readline().rstrip().split()))

def N():
	return int(input())

def print_list(l):
	print(' '.join(map(str, l)))
for _ in range(N()):
	n = input()
	a = [0, 1, 3, 6, 10]
	print(10 * (int(n[0]) - 1) + a[len(n)])


for j in range(int(input())):
	a = int(input())
	a = str(a)
	o = list(a)
	f = (int(o[0]) - 1) * 10
	if len(o) == 1:
		f = f + 1
	elif len(o) == 2:
		f = f + 3
	elif len(o) == 3:
		f = f + 6
	elif len(o) == 4:
		f = f + 10
	print(f)


from sys import stdout, stdin
from collections import defaultdict, deque
import math
t = int(stdin.readline())
for _ in range(t):
	s = input()
	n = len(s)
	k = int(s[0])
	if n == 1:
		print((k - 1) * 10 + 1)
	elif n == 2:
		print((k - 1) * 10 + 3)
	elif n == 3:
		print((k - 1) * 10 + 6)
	else:
		print((k - 1) * 10 + 10)


for pp in range(0, int(input())):
	n = list(input())
	m = len(n)
	c = 10 * (int(n[0]) - 1)
	if m == 1:
		c += 1
	elif m == 2:
		c += 3
	elif m == 3:
		c += 6
	else:
		c += 10
	print(c)


import bisect

def solve(s):
	n = int(s[0])
	l = len(s)
	return int((n - 1) * 10 + l * (l + 1) / 2)
	pass
t = int(input())
ans = []
for i in range(t):
	s = input()
	ans.append(solve(s))
for test in ans:
	print(test)


tests = int(input())
for i in range(tests):
	n = input()
	total = 0
	if len(n) == 4:
		total += 10
	elif len(n) == 3:
		total += 6
	elif len(n) == 2:
		total += 3
	else:
		total += 1
	total += (int(*set(n)) - 1) * 10
	print(total)