Today at the lesson of mathematics, Petya learns about the digital root.

The digital root of a non-negative integer is the single digit value obtained by an iterative process of summing digits, on each iteration using the result from the previous iteration to compute a digit sum. The process continues until a single-digit number is reached. 

Let's denote the digital root of $x$ as $S(x)$. Then $S(5)=5$, $S(38)=S(3+8=11)=S(1+1=2)=2$, $S(10)=S(1+0=1)=1$.

As a homework Petya got $n$ tasks of the form: find $k$-th positive number whose digital root is $x$.

Petya has already solved all the problems, but he doesn't know if it's right. Your task is to solve all $n$ tasks from Petya's homework.


-----Input-----

The first line contains a single integer $n$ ($1 \le n \le 10^3$) — the number of tasks in Petya's homework. The next $n$ lines contain two integers $k_i$ ($1 \le k_i \le 10^{12}$) and $x_i$ ($1 \le x_i \le 9$) — $i$-th Petya's task in which you need to find a $k_i$-th positive number, the digital root of which is $x_i$.


-----Output-----

Output $n$ lines, $i$-th line should contain a single integer — the answer to the $i$-th problem.


-----Example-----
Input
3
1 5
5 2
3 1

Output
5
38
19

Difficulty: interview

Starter code:

Solutions:
t = int(input())

for case in range(0,t):
	x, n = map(int, input().split())
	print(n+(x-1)*9)

for _ in range(int(input())):
  k,x=list(map(int, input().split()))
  print((k-1)*9+x)


for i in range(int(input())):
    n,k=[int(x) for x in input().split()]
    print(9*(n-1)+k)


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

for n in range(ii()):
    k, x = mi()
    ans = 9 * (k - 1) + x
    print(ans)


n=int(input())
for x in range(n):
    k,x=map(int,input().split())
    print(9*(k-1)+x)

for i in range(int(input())):
    k, x = list(map(int, input().split()))
    print(9*(k - 1) + x)



n = int(input())

for _ in range(n):
    k,x = [int(x) for x in input().split()]
    print(x+9*(k-1))


q = int(input())

for _ in range(q):
    a, b = map(int, input().split())
    print((a-1)*9+b)

#JMD
#Nagendra Jha-4096

 
import sys
import math

#import fractions
#import numpy
 
###File Operations###
fileoperation=0
if(fileoperation):
    orig_stdout = sys.stdout
    orig_stdin = sys.stdin
    inputfile = open('W:/Competitive Programming/input.txt', 'r')
    outputfile = open('W:/Competitive Programming/output.txt', 'w')
    sys.stdin = inputfile
    sys.stdout = outputfile

###Defines...###
mod=1000000007
 
###FUF's...###
def nospace(l):
    ans=''.join(str(i) for i in l)
    return ans
 
 
 
##### Main ####
t=int(input())
for tt in range(t):
    #n=int(input())
    k,x= map(int, sys.stdin.readline().split(' '))
    if(x%9):
        print(9*(k-1)+(x%9))
    else:
        print(9*k)
    #a=list(map(int,sys.stdin.readline().split(' ')))
    
    
#####File Operations#####
if(fileoperation):
    sys.stdout = orig_stdout
    sys.stdin = orig_stdin
    inputfile.close()
    outputfile.close()

q = int(input())
for i in range(q) :
    a, b = list(map(int, input().split()))
    print((a - 1) * 9 + b)


for _ in range(int(input())):
    k,x = list(map(int,input().split()))
    print(9*k-9+x)


for _ in[0]*int(input()):
 k,x=list(map(int,input().split()))
 print(x+(k-1)*9)


import math
import bisect
import itertools
import sys
I=lambda : sys.stdin.readline()
mod=10**9 +7
'''fact=[1]*100001
ifact=[1]*100001
for i in range(1,100001):
    fact[i]=((fact[i-1])*i)%mod
    ifact[i]=((ifact[i-1])*pow(i,mod-2,mod))%mod
def ncr(n,r):
    return (((fact[n]*ifact[n-r])%mod)*ifact[r])%mod
def npr(n,r):
    return (((fact[n]*ifact[n-r])%mod))
    '''


def mindiff(a):
    b=a[:]
    b.sort()
    m=10000000000
    for i in range(len(b)-1):
        if b[i+1]-b[i]<m:
            m=b[i+1]-b[i]
    return m
    
def lcm(a,b):
    return a*b//math.gcd(a,b)

    
def merge(a,b):
    i=0;j=0
    c=0
    ans=[]
    while i<len(a) and j<len(b):
        if a[i]<b[j]:
            ans.append(a[i])
            i+=1
        else:
            ans.append(b[j])
            c+=len(a)-i
            j+=1
    ans+=a[i:]
    ans+=b[j:]
    return ans,c
def mergesort(a):
    if len(a)==1:
        return a,0
    mid=len(a)//2   
    left,left_inversion=mergesort(a[:mid])
    right,right_inversion=mergesort(a[mid:])
    m,c=merge(left,right)
    c+=(left_inversion+right_inversion)
    return m,c
    
def is_prime(num):
    if num == 1: return False
    if num == 2: return True
    if num == 3: return True
    if num%2 == 0: return False
    if num%3 == 0: return False
    t = 5
    a = 2
    while t <= int(math.sqrt(num)):
        if num%t == 0: return False
        t += a
        a = 6 - a
    return True
    
  
def ceil(a,b):
    if a%b==0:
        return a//b
    else:
        return (a//b + 1)

def binsearch(arr,b,low,high):
    if low==high:
        return low
    if arr[math.ceil((low+high)/2)]<b:
        return binsearch(arr,b,low,math.ceil((low+high)/2) -1 )
    else:
        return binsearch(arr,b,math.ceil((low+high)/2),high)
def ncr1(n,r):
    s=1
    for i in range(min(n-r,r)):
        s*=(n-i)
        s%=mod
        s*=pow(i+1,mod-2,mod)
        s%=mod
    return s
    
def calc(n,m,r):
    s=0
    for i in range(0,r+1,2):
        s+=ncr1(n,i)*ncr1(m,i)
        s%=mod
    return s    
    
def modu(a,n):
    if a%n==0:
        return n
    return a%n

#/////////////////////////////////////////////////////////////////////////////////////////////////

for i in range(int(input())):
    k,n=list(map(int,input().split()))
    print(n + 9*(k-1))
    


def get():
    return list(map(int,input().split()))
n=int(input())
for i in range(n):
    a,b=get()
    print(9*(a-1)+b)


a=int(input())
for i in range(a):
    b,c=list(map(int,input().split()))
    print(b*9-9+c)


for _ in range(int(input())):
  n,k=map(int,input().split())
  print(9*n+k-9)

for _ in range(int(input())):
    k,x=map(int,input().split())
    print(9*(k-1)+x)

for _ in range(int(input())):
    k,x=map(int,input().split())
    print((k-1)*9+x)

n=int(input())
for i in range(n):
	k,x=map(int,input().split())
	print(x+(k-1)*9)

n = int(input())
for i in range(n):
    k,x = map(int, input().split())
    print(x + 9*(k-1))

import re, math, decimal, bisect
def read(): return input().strip()
def iread(): return int(input().strip())
def viread(): return [int(_) for _ in input().strip().split()]

for _ in range(iread()):
	k, x = viread()
	print(x + 9 * (k - 1))


n=int(input())

for i in range(n):
	k,x=map(int,input().split())

	print(9*(k-1)+x)

t=int(input())
for z in range(t):
    k,x=[int(x) for x in input().split()]
    for i in range(x+1,x+10):
        p=i%9
        if p==0:
            p=9
        if p==x:
            diff=i-x
            break
    ans=x+(k-1)*diff
    #print(diff)
    print(ans)