Problem: You are given two positive integers n and k. Print the k-th positive integer that is not divisible by n.

For example, if n=3, and k=7, then all numbers that are not divisible by 3 are: 1, 2, 4, 5, 7, 8, 10, 11, 13 .... The 7-th number among them is 10.

Input

The first line contains an integer t (1 ≤ t ≤ 1000) — the number of test cases in the input. Next, t test cases are given, one per line.

Each test case is two positive integers n (2 ≤ n ≤ 10^9) and k (1 ≤ k ≤ 10^9).

Output

For each test case print the k-th positive integer that is not divisible by n.

Example

Input


6
3 7
4 12
2 1000000000
7 97
1000000000 1000000000
2 1


Output


10
15
1999999999
113
1000000001
1

Solution (in PYTHON3):

Solution:
########################################

#            SUBTRACTIONS              #

########################################

# for _ in range(int(input())):
#     a, b = map(int, input().split())
#     c = 0
#     while(min(a, b) != 0):
#         ma = max(a, b)
#         mi = min(a, b)
#         a = mi
#         b = ma
#         c += b//a
#         b = b % a
#     print(c)

########################################

#             CANDIES                 #

########################################

# from math import log2, floor, ceil
# for _ in range(int(input())):
#     a = int(input())
#     c = ceil(log2(a))
#     # print(c)
#     for i in range(c, 0, -1):
#         if((a//((2**i)-1)) == ceil(a/((2**i)-1))):
#             print((a//((2**i)-1)))
#             break

########################################

#         VASYA AND SOCKS              #

########################################

# a, b = map(int, input().split())
# c = (a-1)//(b-1)
# print(a+c)

########################################

#       MULTIPLY BY 2, DIVIDE BY 6     #

########################################

# for _ in range(int(input())):
#     n = int(input())
#     if(n == 1):
#         print(0)
#     else:
#         op = 0
#         while(True):
#             if(n % 6 == 0):
#                 n = n//6
#                 op += 1
#             elif((n-3) % 6 == 0):
#                 n = (n*2)//6
#                 op += 2
#             else:
#                 op = -1
#                 break
#             if(n == 1):
#                 break
#         print(op)

########################################

#      Kana and Dragon Quest game      #

########################################

# for _ in range(int(input())):
#     h, n, m = map(int, input().split())
#     if((h-(m*10)) <= 0):
#         print("YES")
#     else:
#         for i in range(n):
#             if(h <= 0):
#                 print("YES")
#                 break
#             h = (h//2)+10
#         if(h > 0):
#             if((h-(m*10)) <= 0):
#                 print("YES")
#             else:
#                 print("NO")

########################################

#      rice bag a+B waala              #

########################################

# for _ in range(int(input())):
#     # print(int(input()))
#     n, a, b, c, d = map(int, input().split())
#     if(n*(a-b) > (c+d) or n*(a+b) < (c-d)):
#         print("NO")
#     else:
#         print("YES")

########################################

#              FOOD BUYING             #

########################################

# for _ in range(int(input())):
#     a = int(input())
#     b = 0
#     while(a >= 10):
#         b = b+((a//10)*10)
#         a = (a % 10)+(a//10)

#     print(a+b)

########################################

#           Avoiding Zeroes            #

########################################

# for _ in range(int(input())):
#     a = int(input())
#     arr = list(map(int, input().split()))

#     b = 0
#     c = ""
#     sn = 0
#     sp = 0
#     for i in range(a):
#         b += arr[i]
#         if(arr[i] > 0):
#             sp += arr[i]
#         elif(arr[i] < 0):
#             sn += abs(arr[i])
#         if(arr[i] == 0):
#             c += " 0"
#     if(sn > sp):
#         ar = sorted(arr)
#     elif(sp > sn):
#         ar = sorted(arr, reverse=True)
#     if(b != 0):
#         print("YES\n")
#         print(" ".join(str(x) for x in ar if x != 0), end='')
#         print(c)
#     else:
#         print("NO")

########################################

#             FOOTBALL                 #

########################################

# s = input()
# if('0000000' in s or '1111111' in s):
#     print("YES")
# else:
#     print("NO")

########################################

#               TWINS                  #

########################################

# n = int(input())
# arr = list(map(int, input().split()))
# s = sum(arr)
# c = su = 0
# for i in range(n):
#     for j in range(n-i-1):
#         if(arr[j] > arr[j+1]):
#             arr[j], arr[j+1] = arr[j+1], arr[j]
#     su += arr[-1-i]
#     c += 1
#     if(su > (s-su)):
#         break
# print(c)

########################################

#            cAPS LOCK                 #

########################################

# s = input()
# a = str(s[0].upper())+s[1:].lower()
# if(s.upper() == s):
#     print(s.lower())
# elif(a[1:].upper() == s[1:]):
#     print(a)
# else:
#     print(s)

########################################

#            DUBSTEPS                  #

########################################

# s = list(map(str, input().split("WUB")))
# print(" ".join(s))

# print(*input().split("WUB"))

########################################

#        anton and polyhedrons         #

########################################

# a = {"Tetrahedron": 4, "Cube": 6, "Octahedron": 8,
#      "Dodecahedron": 12, "Icosahedron": 20}
# s = 0
# for i in range(int(input())):
#     s += a[input()]
# print(s)

########################################

#            Move Brackets             #

########################################

# for _ in range(int(input())):
# a = input()
# s = input()
# cc = 0
# c = 0
# for i in s:
#     if(i == ')'):
#         cc += 1
#     else:
#         cc -= 1
#     if(i == ')' and cc > 0):
#         c += 1
#         cc = 0
# print(c)

########################################

#              Chat Room               #

########################################

# s = input()
# st = "hello"
# a = -1
# for i in s:
#     if(st[a+1] == i):
#         a += 1
#     if(a == 4):
#         break
# if(a < 4):
#     print("NO")
# else:
#     print("YES")

########################################

#            TWO SUBSTRING             #

########################################

# def find(s, l):
#     a = ''
#     for i in range(0, l, 2):
#         a = s[i:i+2]
#         a = a[::-1]
#         if(a in s and len(a) == 2):
#             return True
#     for i in range(1, l, 2):
#         a = s[i:i+2]
#         a = a[-1:]
#         if(a in s and len(a) == 2):
#             return True
#     return False

# a = input()
# l = len(a)
# f = 0
# if(l <= 3):
#     print("NO")
# else:
#     s = a
#     if("AB" in s):
#         s = s.replace("AB", " ", 1)
#         if("BA" in s):
#             print("YES")
#             f = 1
#         # print(s)
#     s = a
#     if("BA" in s and f == 0):
#         s = s.replace("BA", " ", 1)
#         if("AB" in s):
#             print("YES")
#             f = 1
#     if(f == 0):
#         print("NO")

########################################

#               LECTURE                #

########################################

# a = {}
# n, m = map(int, input().split())
# for i in range(m):
#     x, y = map(str, input().split())
#     if(len(x) > len(y)):
#         a[x] = y
#     else:
#         a[x] = x
# b = [str(x) for x in input().split()]
# for j in b:
#     print(a[j], end=" ")
# print("\n")

########################################

#              FOOTBALL                #

########################################

# n = int(input())
# a = {}
# for i in range(n):
#     s = input()
#     if(s in a.keys()):
#         a[s] += 1
#     else:
#         a[s] = 1
# sc = a.values()
# t = max(sc)
# for k, v in a.items():
#     if(v == t):
#         print(k)

########################################

#        Xenia and Ringroad            #

########################################

# n, m = map(int, input().split())
# vi = list(map(int, input().split()))
# c = vi[0] - 1
# co = vi[0]
# for i in range(1, m):
#     if(co <= vi[i]):
#         c += vi[i] - co
#         co = vi[i]
#     else:
#         c += n - (co - vi[i])
#         co = vi[i]
# print(c)

########################################

#              TAXI                    #

########################################

# n = int(input())
# a = list(map(int, input().split()))

# one = a.count(1)
# two = a.count(2)
# three = a.count(3)
# four = a.count(4)

# c = 0
# c += (two//2) + four + three
# if(three >= one):
#     if(two % 2 == 1):
#         c += 1
#     print(c)
# else:
#     d = one - three
#     if(two % 2 == 1):
#         c += 1
#         d -= 2
#     if(d > 0):
#         if(d//4 > 0):
#             if(d % 4 == 0):
#                 c += d//4
#             else:
#                 c += (d//4)+1
#         else:
#             c += 1
#     print(c)

########################################

#         Two Arrays And Swaps         #

########################################


# for _ in range(int(input())):
#     n, k = map(int, input().split())
#     a = list(map(int, input().split()))
#     b = list(map(int, input().split()))

#     sa = sum(a)
#     sb = sum(b)
#     if(k == 0):
#         print(sa)
#     else:
#         a.sort()
#         b = sorted(b, reverse=True)
#         for i in range(k):
#             # print(i)
#             sa = max(sa + b[i] - a[i], sa)
#         print(sa)


########################################

#            String Task               #

########################################

# a = input()
# for i in a:
#     if(i not in ["A", "O", "Y", "E", "U", "I", "a", "o", "y", "e", "u", "i"]):
#         print('.'+i.lower(), end='')
# print('\n')

########################################

#           binary search              #

########################################

# a, e, x = map(int, input().split())
# big = a - e
# small = e - 1
# l = 0
# r = a
# c = a-1
# ans = 1
# while(l < r):
#     m = (l+r)//2
#     if(m < x):
#         c -= 1
#         l = m+1
#         ans *= small % ((10**9)+7)
#         small -= 1
#     elif(m == x):
#         ans = ans
#         l = m+1
#     else:
#         c -= 1
#         ans *= big % ((10**9)+7)
#         big -= 1
#         r = m
# f = 1
# for i in range(1, c+1):
#     f *= i % ((10**9)+7)
# print((ans*f) % ((10**9)+7))

########################################

#         compairing time              #

########################################

# import time
# a = [5]*1000000
# st = time.time()
# s = sum(a)
# en = time.time()
# print(s)
# print(en-st)

# st = time.time()
# sum = 0
# low = 0
# high = 1000000 - 1
# while(low <= high):
#     if(low == high):
#         sum += a[low]
#         low += 1
#         high -= 1
#     else:
#         sum += a[low] + a[high]
#         low += 1
#         high -= 1
# en = time.time()
# print(sum)
# print(en-st)

# st = time.time()
# s = 0
# for i in a:
#     s += i
# en = time.time()
# print(s)
# print(en-st)

########################################

#       Numbers on Whiteboard          #

########################################

# from math import ceil
# for jai_Shree_RAM in range(int(input())):
#     n = int(input())
#     print(2)
#     l = n
#     while(n > 1):
#         n -= 1
#         print("{} {}".format(l, n))
#         l = ceil((l + n)/2)

########################################

#        Queue at the School           #

########################################

# n, t = map(int, input().split())
# s = input()
# for i in range(t):
#     s = s.replace('BG', 'GB')
# print(s)

########################################

#              Puzzels                 #

########################################

# n, m = map(int, input().split())
# ar = sorted(list(map(int, input().split())))
# ans = 1001
# for i in range(m-n+1):
#     ans = min(ans, (ar[i+n-1]-ar[i]))
# print(ans)

########################################

#       C. Registration system         #

########################################

# a = []
# for i in range(int(input())):
#     s = input()

# AFTER HASHING !!!!!!!!

########################################

#            A. Cut Ribbon             #

########################################
# import sys

# sys.setrecursionlimit(400001)


# def cuts(n, a, b, c):
#     if(n == 0):
#         return 0
#     if(n < 0):
#         return -1
#     res = max(cuts(n-a, a, b, c), cuts(n-b, a, b, c), cuts(n-c, a, b, c))
#     if(res == -1):
#         return -1
#     return res+1


# n, a, b, c = map(int, input().split())
# ans = 0
# if(1 in (a, b, c)):
#     print(n)
# elif(n % min(a, b, c) == 0):
#     print(n//min(a, b, c))
# else:
#     for x in range(4001):
#         for y in range(4001):
#             l = n - (a*x+b*y)
#             if(l < 0):
#                 break
#             if(l % c == 0):
#                 ans = max(ans, x+y+(l // c))
#     print(ans)

########################################

#              B. Worms                #

########################################

# from bisect import bisect_left
# n = int(input())
# a = list(map(int, input().split()))
# q = int(input())
# qr = list(map(int, input().split()))
# worms = []
# s = 0
# for i in a:
#     s += i
#     # print(s)
#     worms.append(s)
# # print(a)
# for i in qr:
#     print(bisect_left(worms, i)+1)

########################################

#        C. Two Teams Composing        #

########################################

# for jai_shree_RAM in range(int(input())):
#     n = int(input())
#     a = list(map(int, input().split()))
#     if(n == 1):
#         print(0)
#     else:
#         co = [0]*(n+1)
#         for i in a:
#             co[i] += 1
#         z = co.count(0)
#         if(z == 1):
#             print(1)
#         else:
#             on = 0
#             m = 0
#             for i in co:
#                 if(i != 0):
#                     on += 1
#                 if(i > 1):
#                     m = max(i, m)
#             if(on == m):
#                 print(on - 1)
#             else:
#                 print(min(on, m))

########################################

#      C. K-th Not Divisible by n      #

########################################

from math import ceil
for jai_shree_RAM in range(int(input())):
    a, b = map(int, input().split())
    n = ceil(b/(a-1))
    m = a*(n-1) + (b - ((a-1)*(n-1)))
    print(m)