Chef is baking delicious cookies today! Since Chef is super hungry, he wants to eat at least $N$ cookies.
Since Chef is a messy eater, he drops a lot of crumbs. Crumbs of $B$ cookies can be put together to make a new cookie! 
Given $N$ and $B$, help Chef find out the minimum number of cookies he must initially bake, $A$, to satisfy his hunger.

-----Input:-----
- First line will contain $T$, number of testcases. Then the testcases follow. 
- Each testcase contains of  two space separated integers $N, B$. 

-----Output:-----
For each test case, print a single integer $A$, the minimum number of cookies Chef must bake initially.

-----Constraints-----
- $1 \leq T \leq 1000$
- $1 \leq N \leq 1000000000$
- $2 \leq B \leq 1000000000$

-----Sample Input 1:-----
1
3 2

-----Sample Output 1:-----
2

-----Sample Input 2:-----
1
11 2

-----Sample Output 2:-----
6

-----Explanation 2:-----
Chef initially make 6 cookies. From the crumbs, Chef makes 3 new cookies with no crumbs left over. From the crumbs of the new cookies, Chef makes 1 new cookie and have crumbs left from one cookie. From the new cookie, Chef gets more crumbs. He adds the crumbs and gets one last cookie. After eating that, there are not enough crumbs left to make a new cookie. So a total of 11 cookies are consumed!

Difficulty: interview

Starter code:

Solutions:
for i in range(int(input())):
 n,b=map(int,input().split())
 ans=n-((n-1)//b)
 print(ans)

t = int(input())
for i in range(t):
 #n for number of cookies and b for crumbs
 n , b = map(int,input().split(" "))
 if n == b:
  print(n)
 elif n%b == 0:
  print(n - n//b + 1)
 else:
  print(n - n//b)

# cook your dish here
for _ in range(int(input())):
 N,B = map(int,input().split())
 ans = N-((N-1)//B)
 print(ans)

def f():
 t=int(input())
 while t>0:
  t-=1
  n,b=map(int,input().split())
  if b>=n:
   print(n)
  else:
   if n%b==0:
    ans=((n//b)-1)*(b-1)+b
    print(ans)
   else:
    ans=(((n-1)//b)-1)*(b-1)+b+((n-1)%b)
    print(ans)
f()

# cook your dish here
for _ in range(int(input())):
 n,b=[int(x) for x in input().split()]
 print(n-int((n-1)/b))


# cook your dish here
for _ in range(int(input())):
 n,b=[int(x) for x in input().split()]
 print(n-int((n-1)/b))


# cook your dish here
for i in range(int(input())):
 n,b=list(map(int,input().split()))
 print(1 + n*(b-1)//b)


# cook your dish here
for i in range(int(input())):
  a,b=list(map(int,input().split()))
  print(a- int(((a-1)/b)))


for _ in range(int(input())):
 n,b=[int(x) for x in input().split()]
 print(n-int((n-1)/b))


# cook your dish here
t=int(input())
for i in range(t):
 n,b=list(map(int,input().split()))
 q=n//b 
 if n%b==0:
  a=(n-q)+1 
 else:
  a=n-q 
 print(a)
 


t=int(input())
for i in range(t):
 (n,b)=map(int, input().split())
 x=(n//b)
 if n%b==0:
  a=(n-x)+1
 else:
  a=n-x
 print(a)

t=int(input())
for _ in range(t):
 n,b=list(map(int,input().split()))
 low=1
 high=n
 if b==1:
  print(1)
  continue
 while low<high and abs(high-low)>4:

  
  mid=(low+high)//2
  a=mid//b
  aa=mid%b
  d=mid
  while a:
   #   print(a,aa)
   d+=a
   tt=a+aa
   a=tt//b
   aa=tt%b
  if d>=n:
   high=mid
  if d<n:
   low=mid+1
 
 for mid in range(low,high+1):
  a=mid//b
  aa=mid%b
  d=mid
  while d<n and a:
   d+=a
   tt=a+aa
   a=tt//b
   aa=tt%b
  if d>=n:
   tt=mid
   break
 print(tt)
  


t=int(input())
for _ in range(t):
 n,b=list(map(int,input().split()))
 low=0
 high=n
 while low<high:
  mid=(low+high)//2
  cook=mid
  left=mid
  while True:
   book=left//b
   if book==0:
    break
   left=book+left%b
   cook+=book
  #  print(low,high,mid,cook)
  if high-low<3:
   for i in range(low,high+1):
    cook=i
    left=i
    while True:
     book=left//b
     if book==0:
      break
     left=book+left%b
     cook+=book
    ans=i
    if cook>=n:
     break
   break
  if cook>n:
   ans=mid
   high=mid
  elif cook<n:
   low=mid
  if cook==n:
   ans=mid
   high=mid
 print(ans)
   


# cook your dish here
for _ in range(int(input())):
 n,b=list(map(int,input().split()))
 ans=n-n//b
 if b==1:
  print(1)
 elif n%b:
  print(ans)
 else:
  print(ans+1)

##//author : 'Amit Singh Sansoya @amit3200'
##//it was all meant to happen as i was all talk!
def finder(k):
 eaten=0
 crumbs=0
 while k>0:
  eaten+=k
  crumbs+=k
  k=crumbs//b
  crumbs%=b
 return eaten

def search(N):
 lo=1
 hi=N
 while lo<hi:
  mid=(lo+hi)//2
  total=finder(mid)
  if total<n:
   lo=mid+1
  else:
   hi=mid
 print(hi)

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


import math
t=int(input())
while(t>0):
 n,b=map(int,input().split())
 tobemade=math.ceil(((n*(b-1))+1)/b)
 print(tobemade)
 t-=1

def count(mid,b):
 ans=mid 
 crumb=mid 
 while crumb>=b:
  ans+=crumb//b 
  crumb=crumb//b+crumb%b 
 return ans
for _ in range(int(input())):
 n,b=map(int,input().split())
 low=1 
 high=10**11
 while low<=high:
  mid=(low+high)//2
  if count(mid,b)>=n:
   high=mid-1 
   ans=mid 
  else:
   low=mid+1 
 print(ans)

t=int(input())
for i in range(t):
 n,b=map(int,input().split())
 a=n-n//b
 if(n%b==0):
  a=a+1
 print(a)

t=int(input())
for i in range(t):
 n,b=list(map(int,input().split()))
 a=n-n//b
 if(n%b==0):
  a=a+1
 print(a)