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

Difficulty: introductory

Starter code:

Solutions:
#   ==========     //\\       //||     ||====//||
#       ||        //  \\        ||     ||   // ||
#       ||       //====\\       ||     ||  //  ||
#       ||      //      \\      ||     || //   ||
#   ========== //        \\  ========  ||//====|| 
#  code


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()

def __starting_point():
    main()
__starting_point()

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

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 list(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)


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 _ 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)

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 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())
for _ in range(t):
    x = input()
    ans = 0
    ans += (int(x[0])-1)*10
    ans += len(x)*(len(x)+1)//2
    print(ans)

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)

import sys, math
import io, os
#data = io.BytesIO(os.read(0,os.fstat(0).st_size)).readline
#from bisect import bisect_left as bl, bisect_right as br, insort
#from heapq import heapify, heappush, heappop
#from collections import defaultdict as dd, deque, Counter
#from itertools import permutations,combinations
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')
#from decimal import Decimal
#from fractions import Fraction
#sys.setrecursionlimit(100000)
#INF = float('inf')
mod = int(1e9)+7


for t in range(int(data())):
    s=data()
    ans=10*int(s[0])-10+(len(s)*(len(s)+1))//2
    out(ans)


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)


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()

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

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())
        # s = input().strip()
        # x,y = map(int, input().strip().split(" "))
        # arr = list(map(int, input().strip().split(" ")))
        
        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 = []
        # s = ''.join(random.choices(string.ascii_lowercase, k = str_size))
        
        for j in range(arr_size):
            num = randrange(min_range, max_range, step)
            k.append(num)
        
        solve(n, arr)
        print("<-------- DEBUG ----------->")

    return 

def __starting_point():
    main()
    # test()
        

__starting_point()

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)

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


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 math
test = int(input())
for t in range(test):
    tt = 0
    pp = 0
    cc = ""
    ss = ""
    dd = 1
    cnttt = 0
    #write yoour code here
    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)
    



'''
    Auther: ghoshashis545 Ashis Ghosh
    College: jalpaiguri Govt Enggineering College

'''
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
# mod=998244353
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()

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


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)

def main():
    x = int(input())
    n = int(str(x)[0])
    l = len(str(x))
    ans = 10 * (n-1)
    ans += l * (l+1) // 2
    print(ans)



for _ in range(int(input())):
    main()

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)


t = int(input())

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

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)