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
[{"code": "#   ==========     //\\\\       //||     ||====//||\n#       ||        //  \\\\        ||     ||   // ||\n#       ||       //====\\\\       ||     ||  //  ||\n#       ||      //      \\\\      ||     || //   ||\n#   ========== //        \\\\  ========  ||//====|| \n#  code\n\n\ndef solve():\n    x = int(input())\n    ans = 0\n    ok = 0\n\n    for i in range(1, 10):\n        n = 0\n        for j in range(4):\n            n = n * 10 + i\n            ans += (j + 1)\n            if n == x:\n                ok = 1\n                break\n        if ok:\n            break\n    print(ans)\n\ndef main():\n    t = 1\n    t = int(input())\n    for _ in range(t):\n        solve()\n\ndef __starting_point():\n    main()\n__starting_point()", "passed": true, "time": 0.15, "memory": 14248.0, "status": "done"}, {"code": "def solve():\n    n = input()\n    print(int(n) % 10 * 10 + len(n) * (len(n) + 1) // 2 - 10)\nfor i in range(int(input())):\n    solve()", "passed": true, "time": 0.14, "memory": 14168.0, "status": "done"}, {"code": "rn=lambda:int(input())\nrl=lambda:list(map(int,input().split()))\nrns=lambda:map(int,input().split())\nrs=lambda:input()\nyn=lambda x:print('Yes') if x else print('No')\nYN=lambda x:print('YES') if x else print('NO')\n\nfor _ in range(rn()):\n    x=rs()\n    n=int(x[0])\n    ans=10*(n-1)\n    for i in range(len(x)+1):\n        ans+=i\n    print(ans)\n", "passed": true, "time": 1.29, "memory": 14368.0, "status": "done"}, {"code": "for _ in range(int(input())):\n\tn=int(input())\n\tans=0\n\tfor i in range(1,10):\n\t\tf=0\n\t\tfor j in range(1,5):\n\t\t\tk=int(str(i)*j)\n\t\t\tans+=len(str(k))\n\t\t\tif k==n:f=1;break\n\t\tif f:break\n\tprint(ans)", "passed": true, "time": 0.15, "memory": 14088.0, "status": "done"}, {"code": "import sys\ninput = sys.stdin.readline\n\ndef main():\n    x = input().strip()\n    n = int(x[0])\n    l = len(x)\n    ans = 10 * (n - 1) + l * (l + 1) // 2\n    print(ans)\n    \nfor _ in range(int(input())):\n    main()", "passed": true, "time": 0.14, "memory": 14052.0, "status": "done"}, {"code": "for t in range(int(input())):\n    x = input()\n    ans = []\n    for i in range(1,10):\n        for j in range(1,5):\n            ans.append(str(i)*j)\n    cnt = 0\n    for i in ans:\n        if i==x:\n            cnt+=len(i)\n            break\n        else:\n            cnt+=len(i)\n    print(cnt)", "passed": true, "time": 0.16, "memory": 14260.0, "status": "done"}, {"code": "t = int(input())\nfor _ in range(t):\n    x = input()\n    ans = 0\n    ans += (int(x[0])-1)*10\n    ans += len(x)*(len(x)+1)//2\n    print(ans)", "passed": true, "time": 0.19, "memory": 14272.0, "status": "done"}, {"code": "for __ in range(int(input())):\n    n = input()\n    ans = (int(n[0]) - 1) * 10 + 1\n    if len(n) >= 2:\n        ans += 2\n    if len(n) >= 3:\n        ans += 3\n    if len(n) >= 4:\n        ans += 4\n    print(ans)", "passed": true, "time": 0.15, "memory": 14264.0, "status": "done"}, {"code": "import sys, math\nimport io, os\n#data = io.BytesIO(os.read(0,os.fstat(0).st_size)).readline\n#from bisect import bisect_left as bl, bisect_right as br, insort\n#from heapq import heapify, heappush, heappop\n#from collections import defaultdict as dd, deque, Counter\n#from itertools import permutations,combinations\ndef data(): return sys.stdin.readline().strip()\ndef mdata(): return list(map(int, data().split()))\ndef outl(var) : sys.stdout.write(' '.join(map(str, var))+'\\n')\ndef out(var) : sys.stdout.write(str(var)+'\\n')\n#from decimal import Decimal\n#from fractions import Fraction\n#sys.setrecursionlimit(100000)\n#INF = float('inf')\nmod = int(1e9)+7\n\n\nfor t in range(int(data())):\n    s=data()\n    ans=10*int(s[0])-10+(len(s)*(len(s)+1))//2\n    out(ans)\n", "passed": true, "time": 1.53, "memory": 14320.0, "status": "done"}, {"code": "for _ in range(int(input())):\n    x = int(input())\n\n    c = 0\n    for i in range(1, 10):\n        k = i\n\n        while i <= 10000:\n            c += len(str(i))\n\n            if i == x:\n                break\n\n            i *= 10\n            i += k\n\n        else:\n            continue\n\n        break\n\n    print(c)\n", "passed": true, "time": 0.2, "memory": 14108.0, "status": "done"}, {"code": "from sys import stdin, stdout\ninput = stdin.readline\nfrom collections import defaultdict as dd\nimport math\ndef geti(): return list(map(int, input().strip().split()))\ndef getl(): return list(map(int, input().strip().split()))\ndef gets(): return input()\ndef geta(): return int(input())\ndef print_s(s): stdout.write(s+'\\n')\n\ndef solve():\n    for _ in range(geta()):\n        a=geta()\n        ans=0\n        ans=10*(a%10-1)\n        while a:\n            ans+=len(str(a))\n            a//=10\n        print(ans)\n\n\ndef __starting_point():\n    solve()\n\n__starting_point()", "passed": true, "time": 0.19, "memory": 14324.0, "status": "done"}, {"code": "t=int(input())\nfor _ in range(t):\n    x=input()\n    a=int(x[0])\n    b=len(x)\n    print(10*(a-1)+(b*(b+1))//2)", "passed": true, "time": 0.14, "memory": 14268.0, "status": "done"}, {"code": "import math\nimport string\nimport random\nfrom random import randrange\nfrom collections import deque\nfrom collections import defaultdict\n\ndef solve(n):\n    ans = 0\n\n    k = n%10\n    \n    ans += 10*(k-1)\n    \n    f = len(str(n))\n    \n    for i in range(1, f+1):\n        ans += i\n\n    print(ans)\n    return \n\ndef main():\n    t = int(input())\n    while t>0:\n        t-=1\n        \n        n = int(input())\n        # s = input().strip()\n        # x,y = map(int, input().strip().split(\" \"))\n        # arr = list(map(int, input().strip().split(\" \")))\n        \n        solve(n)\n        \n    return\n\ndef test():\n    arr_size = 25\n    test_cases = 100\n    min_range = -100\n    max_range = 100\n    str_size = 30\n    step = 1\n    \n    for i in range(test_cases):\n        k = []\n        # s = ''.join(random.choices(string.ascii_lowercase, k = str_size))\n        \n        for j in range(arr_size):\n            num = randrange(min_range, max_range, step)\n            k.append(num)\n        \n        solve(n, arr)\n        print(\"<-------- DEBUG ----------->\")\n\n    return \n\ndef __starting_point():\n    main()\n    # test()\n        \n\n__starting_point()", "passed": true, "time": 0.15, "memory": 14160.0, "status": "done"}, {"code": "import sys\ninput=sys.stdin.readline\nfrom collections import defaultdict as dc\nfrom bisect import bisect_right\nimport math\nfor _ in range(int(input())):\n    n=int(input())\n    x=n%10\n    c=10*(x-1)\n    s=str(n)\n    for i in range(len(s)):\n        c+=i+1\n    print(c)", "passed": true, "time": 0.2, "memory": 14288.0, "status": "done"}, {"code": "for _ in range(int(input())):\n    s=input()\n    ans=10*(int(s[0])-1)\n    l=len(s)\n    if l==1:\n        ans+=1\n    elif l==2:\n        ans+=3\n    elif l==3:\n        ans+=6\n    else:\n        ans+=10\n    print(ans)\n", "passed": true, "time": 0.15, "memory": 14204.0, "status": "done"}, {"code": "t=int(input())\nfor i in range(t):\n    n=input()\n    z=len(n)\n    k=int(n)%10\n    print(round((k-1)*10+(z*(z+1))/2))", "passed": true, "time": 0.14, "memory": 14104.0, "status": "done"}, {"code": "import math\ntest = int(input())\nfor t in range(test):\n    tt = 0\n    pp = 0\n    cc = \"\"\n    ss = \"\"\n    dd = 1\n    cnttt = 0\n    #write yoour code here\n    x = int(input())\n    a = x;cnt = 0\n    while(a!=0):\n        a=a//10\n        cnt+=1\n    a = x%10\n    ans = (a-1)*10+cnt*(cnt+1)//2\n    print(ans)\n    \n\n", "passed": true, "time": 0.14, "memory": 14292.0, "status": "done"}, {"code": "'''\n    Auther: ghoshashis545 Ashis Ghosh\n    College: jalpaiguri Govt Enggineering College\n\n'''\nfrom os import path\nimport sys\nfrom heapq import heappush,heappop\nfrom functools import cmp_to_key as ctk\nfrom collections import deque,defaultdict as dd \nfrom bisect import bisect,bisect_left,bisect_right,insort,insort_left,insort_right\nfrom itertools import permutations\nfrom datetime import datetime\nfrom math import ceil,sqrt,log,gcd\ndef ii():return int(input())\ndef si():return input().rstrip()\ndef mi():return list(map(int,input().split()))\ndef li():return list(mi())\nabc='abcdefghijklmnopqrstuvwxyz'\nmod=1000000007\n# mod=998244353\ninf = float(\"inf\")\nvow=['a','e','i','o','u']\ndx,dy=[-1,1,0,0],[0,0,1,-1]\n\ndef bo(i):\n    return ord(i)-ord('a')\n\nfile = 1\n\n\n\n    \ndef solve():\n\n\n    \n\n    for _ in range(ii()):\n\n        s = si()\n        x = [1,3,6,10]\n        n = len(s)\n        x1 = int(s[0]) \n        print(10*(x1-1) + x[n-1])\n        \n\n        \n\n        \n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n        \ndef __starting_point():\n\n    if(file):\n\n        if path.exists('input.txt'):\n            sys.stdin=open('input.txt', 'r')\n            sys.stdout=open('output.txt','w')\n        else:\n            input=sys.stdin.readline\n    solve()\n\n__starting_point()", "passed": true, "time": 0.15, "memory": 16408.0, "status": "done"}, {"code": "t = int(input())\n\nfor _ in range(t):\n    n = int(input())\n    counting = 0\n    is_done = False\n    for i in range(1,10):\n        for c in range(1,5):\n            curr_int = int(str(i) * c)\n            counting += c\n            if curr_int == n:\n                print(counting)\n                is_done= True\n                break\n\n        if is_done:\n            break\n", "passed": true, "time": 0.19, "memory": 14104.0, "status": "done"}, {"code": "for _ in range(int(input())):\n    n = input()\n    c = int(n[0])\n    ans = (c - 1) * 10\n    k = len(n)\n    for i in range(1, k + 1):\n        ans += i\n    print(ans)", "passed": true, "time": 0.14, "memory": 14160.0, "status": "done"}, {"code": "def main():\n    x = int(input())\n    n = int(str(x)[0])\n    l = len(str(x))\n    ans = 10 * (n-1)\n    ans += l * (l+1) // 2\n    print(ans)\n\n\n\nfor _ in range(int(input())):\n    main()", "passed": true, "time": 0.14, "memory": 14296.0, "status": "done"}, {"code": "for _ in range(int(input())):\n    x = int(input())\n    a = x;cnt = 0\n    while(a!=0):\n        a=a//10\n        cnt+=1\n    a = x%10\n    ans = (a-1)*10+cnt*(cnt+1)//2\n    print(ans)\n", "passed": true, "time": 0.14, "memory": 14036.0, "status": "done"}, {"code": "t = int(input())\n\nfor test in range(t):\n    x = int(input())\n    a = len(str(x))\n    print((x % 10 - 1) * 10 + a * (a + 1) // 2)", "passed": true, "time": 0.14, "memory": 14172.0, "status": "done"}, {"code": "import sys\n\n\ndef read(func=int):\n    return func(sys.stdin.readline().strip())\n\ndef readList(func=int):\n    return list(map(func, sys.stdin.readline().strip().split()))\n\n\nt = read()\nfor _ in range(t):\n    num = read()\n    tot = ((num % 10) - 1) * 10\n    for i in range(len(str(num))):\n        tot += i + 1\n    print(tot)\n", "passed": true, "time": 0.16, "memory": 14192.0, "status": "done"}]