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 \dots$. The $7$-th number among them is $10$.


-----Input-----

The first line contains an integer $t$ ($1 \le t \le 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 \le n \le 10^9$) and $k$ ($1 \le k \le 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

Source: codeforces | Difficulty: EASY
Tags: Sorting

Mathematics


Solutions:
def solve():
	(n, k) = map(int, input().split(' '))
	if k < n:
		print(k)
	else:
		x = k // (n - 1)
		y = x * (n - 1)
		c = k - y
		if c == 0:
			print(n * x - 1)
		else:
			print(c + n * x)
for i in range(int(input())):
	solve()


for t in range(int(input())):
	(n, k) = map(int, input().split())
	if k < n:
		r2 = k
	elif n == 2:
		r2 = k * 2 - 1
	else:
		r2 = n * k // (n - 1)
		if n * k % (n - 1) == 0:
			r2 -= 1
	print(r2)


from __future__ import division, print_function
import sys
if sys.version_info[0] < 3:
	from __builtin__ import xrange as range
	from future_builtins import ascii, filter, hex, map, oct, zip
import os, sys, bisect, copy
from collections import defaultdict, Counter, deque
if os.path.exists('in.txt'):
	sys.stdin = open('in.txt', 'r')
if os.path.exists('out.txt'):
	sys.stdout = open('out.txt', 'w')

def input():
	return sys.stdin.readline()

def mapi(arg=0):
	return map(int if arg == 0 else str, input().split())
for _ in range(int(input())):
	(n, k) = mapi()
	if k < n:
		print(k)
	else:
		res = k // (n - 1) * n
		if k % (n - 1):
			res += k % (n - 1)
		else:
			res -= 1
		print(res)


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


t = int(input())
while t > 0:
	(n, k) = map(int, input().split())
	x = n - 1
	j = k // x
	if k == x * j:
		print(n * j - 1)
	else:
		dif = k - x * j
		print(n * j + dif)
	t -= 1


for _ in range(int(input())):
	(a, k) = [int(i) for i in input().split()]
	print(k + (k - 1) // (a - 1))


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


t = int(input())
for _ in range(0, t):
	(n, k) = map(int, input().split())
	if k < n:
		print(k)
	elif k == n:
		print(n + 1)
	elif n == 2:
		ans = 2 * (k - 1) + 1
		print(ans)
	else:
		lt = n - 1
		cp = k // lt
		ans = n * cp
		re = k % lt
		if re != 0:
			ans += re
		else:
			ans -= 1
		print(ans)


for _ in range(int(input())):
	(n, k) = map(int, input().split())
	v = k // (n - 1)
	if k % (n - 1) == 0:
		print(n * v - 1)
	else:
		print(n * v + k % (n - 1))


def solve():
	(n, k) = map(int, input().split())
	(multiples, ans, exmultiples) = (0, 0, 0)
	multiples = k // n
	ans = k
	while multiples != exmultiples:
		ans += multiples - exmultiples
		temp = k + multiples
		exmultiples = multiples
		multiples = temp // n
	print(ans)
t = int(input())
while t > 0:
	t -= 1
	solve()


from math import floor
for _ in range(int(input())):
	(n, k) = map(int, input().split())
	print(n * (k - 1) // (n - 1) + 1)


from sys import stdin, gettrace
if not gettrace():

	def input():
		return next(stdin)[:-1]

def main():

	def solve():
		(n, k) = map(int, input().split())
		block = (k - 1) // (n - 1)
		rm = (k - 1) % (n - 1) + 1
		print(block * n + rm)
	q = int(input())
	for _ in range(q):
		solve()
main()


t = int(input())
for i in range(t):
	(n, k) = map(int, input().split())
	s = 0
	v = 0
	while True:
		k = k + v
		v = k // n - s
		s = k // n
		if v == 0:
			break
	print(k)


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


for i1 in range(int(input())):
	(n, k) = map(int, input().split())
	if n > k:
		print(k)
	else:
		add = k
		differ = 0
		diff = k
		while diff > 0:
			div = add // n
			diff = div - differ
			add += diff
			differ = div
		print(add)


for _ in range(int(input())):
	(n, k) = [int(i) for i in input().split()]
	if n == 1:
		print(None)
	else:
		a = k // (n - 1) + k
		if a % n == 0:
			a -= 1
		print(a)


import math
t = int(input())
for ii in range(t):
	(n, k) = map(int, input().split())
	if k < n:
		print(k)
	else:
		k -= 1
		n -= 1
		flag = k // n
		print(k + flag + 1)


t = int(input())
for i in range(t):
	li = input().split()
	n = int(li[0])
	k = int(li[1])
	factor = 1
	num = n - 1
	z = int((k - 1) / num)
	print(k + z)


def read_int():
	return int(input().strip())

def read_ints():
	return list(map(int, input().strip().split(' ')))

def solve():
	(n, k) = read_ints()
	if k % (n - 1) == 0:
		return k // (n - 1) * n - 1
	return k // (n - 1) * n - 1 + k % (n - 1) + 1
T = read_int()
for _ in range(T):
	print(solve())


c = int(input())
for z in range(c):
	i = input().split(' ')
	a = int(i[1]) // (int(i[0]) - 1)
	b = int(i[1]) % (int(i[0]) - 1)
	if b == 0:
		print(a * int(i[0]) - 1)
	else:
		print(a * int(i[0]) + b)


t = int(input())
for i in range(t):
	(n, k) = input().split()
	n = int(n)
	k = int(k)
	j = n - 1
	if k % j == 0:
		total = k // j
		total = total + k
		total = total - 1
	else:
		total = k // j
		total = total + k
	print(total)


import io
import os
import sys
from atexit import register
import random
import math
import itertools
DEBUG = False
STRESSTEST = False
if not DEBUG:
	input = io.BytesIO(os.read(0, os.fstat(0).st_size)).readline
sys.stdout = io.BytesIO()
register(lambda : os.write(1, sys.stdout.getvalue()))
tokens = []
tokens_next = 0

def nextStr():
	global tokens, tokens_next
	while tokens_next >= len(tokens):
		tokens = input().split()
		tokens_next = 0
	tokens_next += 1
	if type(tokens[tokens_next - 1]) == str:
		return tokens[tokens_next - 1]
	return tokens[tokens_next - 1].decode()

def nextInt():
	return int(nextStr())

def nextIntArr(n):
	return [nextInt() for i in range(n)]

def print(*argv, end='\n'):
	for arg in argv:
		sys.stdout.write((str(arg) + ' ').encode())
	sys.stdout.write(end.encode())

def genTestCase():
	raise NotImplementedError

def bruteforce(n, k):
	res = set(range(1, 10 ** 5))
	res -= set(range(n, 10 ** 5, n))
	res = sorted(res)
	res = res[k - 1]
	return res

def doStressTest():
	while True:
		curTest = genTestCase()
		mySoln = solve(curTest)
		bruteforceSoln = bruteforce(curTest)
		if mySoln != bruteforceSoln:
			print('### Found case ###')
			print(curTest)
			print(f'{mySoln} should have been: {bruteforceSoln}')
			return

def getRank(cur, n):
	return cur - cur // n

def solve(n, k):
	low = k - 1
	high = 10 ** 10
	while low + 1 < high:
		mid = (low + high) // 2
		if getRank(mid, n) < k:
			low = mid
		else:
			high = mid
	return high
if not DEBUG and STRESSTEST:
	raise Exception('Wrong flags!')
if STRESSTEST:
	doStressTest()
else:
	t = nextInt()
	for _ in range(t):
		n = nextInt()
		k = nextInt()
		print(solve(n, k))
sys.stdout.flush()


t = int(input())

def interval(n, w, w_prime):
	return w_prime // n - w // n
for case in range(t):
	(n, k) = map(int, input().split())
	w = 0
	w_prime = k
	i = float('inf')
	while i:
		i = interval(n, w, w_prime)
		(w, w_prime) = (w_prime, w_prime + i)
	print(w_prime)


import sys
import os
from math import sqrt, log, log2, log10, gcd, floor, pow, sin, cos, tan, pi, inf, factorial
from copy import copy, deepcopy
from sys import exit, stdin, stdout
from collections import Counter, defaultdict, deque
from itertools import permutations
import heapq
from bisect import bisect_left as bl
from bisect import bisect_right as br
from bisect import bisect
mod = 1000000007
iinp = lambda : int(sys.stdin.readline())
inp = lambda : sys.stdin.readline().strip()
strl = lambda : list(inp().strip().split(' '))
intl = lambda : list(map(int, inp().split(' ')))
mint = lambda : map(int, inp().split())
flol = lambda : list(map(float, inp().split(' ')))
flush = lambda : stdout.flush()

def permute(nums):

	def fun(arr, nums, cur, v):
		if len(cur) == len(nums):
			arr.append(cur.copy())
		i = 0
		while i < len(nums):
			if v[i]:
				i += 1
				continue
			else:
				cur.append(nums[i])
				v[i] = 1
				fun(arr, nums, cur, v)
				cur.pop()
				v[i] = 0
				i += 1
		return arr
	res = []
	nums.sort()
	v = [0] * len(nums)
	return fun(res, nums, [], v)

def subsets(res, index, arr, cur):
	res.append(cur.copy())
	for i in range(index, len(arr)):
		cur.append(arr[i])
		subsets(res, i + 1, arr, cur)
		cur.pop()
	return res

def sieve(N):
	root = int(sqrt(N))
	primes = [1] * (N + 1)
	(primes[0], primes[1]) = (0, 0)
	for i in range(2, root + 1):
		if primes[i]:
			for j in range(i * i, N + 1, i):
				primes[j] = 0
	return primes

def bs(arr, l, r, x):
	if x < arr[0] or x > arr[len(arr) - 1]:
		return -1
	while l <= r:
		mid = l + (r - l) // 2
		if arr[mid] == x:
			return mid
		elif arr[mid] < x:
			l = mid + 1
		else:
			r = mid - 1
	return -1

def isPrime(n):
	if n <= 1:
		return False
	if n <= 3:
		return True
	if n % 2 == 0 or n % 3 == 0:
		return False
	p = int(sqrt(n))
	for i in range(5, p + 1, 6):
		if n % i == 0 or n % (i + 2) == 0:
			return False
	return True

def solve():
	(n, k) = mint()
	l = 0
	r = 10 ** 10
	while l < r:
		mid = (l + r) // 2
		if mid - mid // n >= k:
			r = mid
		else:
			l = mid + 1
	print(l)
for _ in range(iinp()):
	solve()


t = int(input())
while t > 0:
	t -= 1
	(n, k) = map(int, input().split())
	z = (k - 1) // (n - 1)
	print(k + z)


t = int(input())
for _ in range(t):
	(n, k) = input().split()
	(n, k) = (int(n), int(k))
	awn = (k + n - 2) // (n - 1) - 1
	print(awn * n + (k - 1) % (n - 1) + 1)


import math
x = int(input())
for _ in range(x):
	(num, th) = map(int, input().split())
	print(math.floor(th + (th - 1) / (num - 1)))


t = int(input())
for _ in range(t):
	(n, k) = map(int, input().split())
	g = n * (k // (n - 1))
	if k % (n - 1) == 0:
		print(g - 1)
	else:
		m = k - (n - 1) * (k // (n - 1))
		print(g + m)


ncases = int(input())
n = 0
k = 0
for x in range(0, ncases):
	(n, k) = tuple([int(x) for x in input().split()])
	x = k
	while x - x // n != k:
		if x - x // n > k:
			x -= x - x // n - k
		else:
			x += k - (x - x // n)
	print(x)


for _ in range(int(input())):
	(n, m) = map(int, input().split())
	not_divisible = n - 1
	mul = int(m / not_divisible)
	dec = m % not_divisible
	if dec == 0:
		dec = -1
	ans = n * mul + dec
	print(ans)


t = int(input())
for _ in range(t):
	(n, k) = map(int, input().split())
	if k < n:
		print(k)
	elif k == n:
		print(k + 1)
	else:
		ans = k * n // (n - 1) - (0 if k * n % (n - 1) else 1)
		print(ans)


n = int(input())
for lmao in range(n):
	(n, k) = map(int, input().split())
	n -= 1
	k -= 1
	div = k // n
	print((n + 1) * div + k % n + 1)


for _ in ' ' * int(input()):
	from math import ceil as c
	(a, b) = map(int, input().split())
	print(b + c(b / (a - 1)) - 1)


import sys
from os import path
if path.exists('C:/Users/prana/Desktop/sublime/input.txt'):
	sys.stdin = open('C:/Users/prana/Desktop/sublime/input.txt', 'r')
	sys.stdout = open('C:/Users/prana/Desktop/sublime/output.txt', 'w')

def solve():
	(n, k) = input().split()
	n = int(n)
	k = int(k)
	temp = k // n
	k += temp
	while k // n != temp:
		v = temp
		temp = k // n
		k = k + k // n - v
	if k % n == 0:
		print(k + 1)
	else:
		print(k)
T = 1
T = int(input())
for _ in range(1, T + 1):
	print('Case #', _, file=sys.stderr)
	solve()


import math

def kthNonDivisible(N, K):
	return K + math.floor((K - 1) / (N - 1))
for i in range(int(input())):
	(N, K) = map(int, input().split())
	print(kthNonDivisible(N, K))


t = int(input())

def search(l, r, n, k):
	m = (l + r) // 2
	x = m - m // n
	if x == k:
		return m if m % n != 0 else m - 1
	elif x > k:
		return search(l, m - 1, n, k)
	else:
		return search(m + 1, r, n, k)
for _ in range(t):
	(n, k) = map(int, input().split())
	print(search(1, 4000000000, n, k))


from collections import deque
from collections import OrderedDict
import math
import sys
import os
from io import BytesIO
import threading
import bisect
limit = 5000000000
for t in range(int(input())):
	(n, k) = map(int, input().split())
	l = 0
	r = limit
	c = 0
	answer = 0
	while l <= r:
		c = l + (r - l) // 2
		number = c - c // n
		if number == k:
			answer = c
			r -= 1
		elif number < k:
			l = c + 1
		else:
			r = c - 1
	print(answer)


t = int(input())
for i in range(t):
	(a, b) = map(int, input().split())
	if a > b:
		print(b)
	elif a == b:
		print(b + 1)
	else:
		k = a * b
		m = a - 1
		if k & 1:
			x = k // m
			if x % a == 0:
				print(x - 1)
			else:
				print(x)
		else:
			x = k // m
			if x % a == 0:
				print(x - 1)
			else:
				print(x)


def resolve():
	t = int(input())
	for _ in range(t):
		(n, k) = map(int, input().split())
		ans = k + (k - 1) // (n - 1)
		print(ans)
resolve()


t = int(input())
while t > 0:
	n = list(map(int, input().split()))
	need = (n[1] - 1) // (n[0] - 1)
	print(n[1] + need)
	t -= 1


for __ in range(int(input())):
	(n, k) = map(int, input().split())
	need = (k - 1) // (n - 1)
	print(k + need)


t = int(input())
for _ in range(t):
	(k, n) = tuple(map(int, input().split(' ')))
	prev = 0
	now = n // k
	while now - prev != 0:
		n += now - prev
		prev = now
		now = n // k
	print(n)


tests = int(input())
for _ in range(tests):
	(n, k) = map(int, input().split())
	res = (k - 1) / (n - 1) + k
	print(int(res))


num = int(input())
for _ in range(num):
	(n, k) = [int(i) for i in input().split()]
	div = k // (n - 1)
	mod = k % (n - 1)
	if mod == 0:
		print(n * div - 1)
	else:
		print(n * div + mod)


from math import *
from collections import *
from operator import itemgetter
import bisect
ii = lambda : int(input())
iia = lambda : list(map(int, input().split()))
isa = lambda : list(input().split())
I = lambda : list(map(int, input().split()))
chrIdx = lambda x: ord(x) - 96
idxChr = lambda x: chr(96 + x)
t = ii()
for _ in range(t):
	(n, k) = iia()
	x = n * floor(k / (n - 1))
	if k % (n - 1) == 0:
		print(x - 1)
	else:
		y = (n - 1) * floor(k / (n - 1))
		if y != 0:
			print(x + k % y)
		else:
			print(x + k)


def k_e_not_div_n(n, k):
	ans = k + k // n
	while ans - ans // n != k:
		ans += k - (ans - ans // n)
	return ans
lines = int(input())
for i in range(lines):
	(n, k) = map(int, input().split())
	print(k_e_not_div_n(n, k))


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


res = []
for _ in range(int(input())):
	(n, k) = map(int, input().split())
	if k % (n - 1) == 0:
		res.append(k // (n - 1) * n - 1)
	else:
		res.append(k // (n - 1) * n + k % (n - 1))
for i in res:
	print(i)


import sys
f = sys.stdin
t = int(f.readline())
for _ in range(t):
	(n, k) = map(int, f.readline().split())
	need = (k - 1) // (n - 1)
	print(k + need)


for _ in range(int(input().strip())):
	(n, k) = map(int, input().strip().split())
	t1 = k // (n - 1)
	t2 = k % (n - 1)
	if t2 == 0:
		print(str(t1 * n - 1))
	else:
		print(str(t1 * n + t2))


def r(t=int):
	return list(map(t, input().split()))

def ri(t=int):
	return t(input())

def cd(it):
	ret_val = dict()
	for v in it:
		ret_val[v] = ret_val.get(v, 0) + 1
	return ret_val
for _ in range(ri()):
	(n, k) = r()
	if k % (n - 1):
		g = k // (n - 1) * n + k % (n - 1)
	else:
		g = k // (n - 1) * n - 1
	print(g)


tests = int(input())
for i in range(tests):
	(n, k) = map(int, input().split())
	z = k
	s = z // n
	while z - z // n != k:
		z += s
		s = s // n
		if s == 0:
			break
	while z - z // n != k:
		z += 1
	print(z)


t = int(input())
for i in range(t):
	(n, k) = [int(a) for a in input().split(' ')]
	v = k
	prev = 0
	while v - v // n < k:
		tmp = v // n
		v += tmp - prev
		prev = tmp
	print(v)


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


t = int(input())
while t != 0:
	t -= 1
	(n, k) = map(int, input().split())
	if k < n:
		print(k)
	else:
		p = k // (n - 1)
		r = k % (n - 1)
		ans = 0
		if r == 0:
			ans = n - 1 + n * (p - 1)
		else:
			ans = r + n * p
		print(ans)


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


t = int(input())
for tests in range(t):
	(n, k) = map(int, input().split())
	p = (k - 1) // (n - 1)
	print(k + p)


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


def solve(m, n, s):
	if m % n == 0:
		return solve(m + 1, n, s)
	if s < n - m % n:
		return m + s
	if m % n != 1:
		return solve(m + n - m % n + 1, n, s - n + m % n)
	return solve(m + s, n, s // n)

def main():
	t = int(input())
	for i in range(t):
		(n, k) = [int(number) for number in input().split()]
		print(solve(1, n, k - 1))
main()


for _ in range(int(input())):
	(n, k) = map(int, input().split(' '))
	s = k // (n - 1)
	k -= s * (n - 1)
	if k == 0:
		k = -1
	print(n * s + k)


for t in range(int(input())):
	(n, k) = map(int, input().split())
	if n != 2:
		temp = k
		sum = k
		flag = False
		while temp >= n:
			sum += temp // n
			temp = temp % n + temp // n
		if k == 1:
			print(1)
		else:
			print(sum)
	else:
		print(2 * k - 1)


import math
t = int(input())
for i in range(t):
	(n, k) = map(int, input().split())
	b = n / (n - 1)
	x = math.ceil(k * b - 1)
	print(x)


import math
t = int(input())
for i in range(0, t):
	nk = input().split()
	n = int(nk[0])
	k = int(nk[1])
	x = n * (k - 1) / (n - 1)
	print(math.floor(x) + 1)


import sys
ip = lambda : sys.stdin.readline()
ipl = lambda : sys.stdin.readline().split()
for _ in range(int(ip())):
	(n, k) = map(int, ipl())
	t1 = k % (n - 1)
	t2 = k // (n - 1)
	if t1 == 0:
		print(n * t2 - 1)
	else:
		print(n * t2 + t1)


t = int(input())
while t:
	(n, k) = map(int, input().split())
	temp = k % (n - 1)
	temp1 = k // (n - 1)
	if k % (n - 1) == 0:
		print(n * temp1 - 1)
	else:
		ans = temp1 * n + temp
		print(ans)
	t -= 1


import math
t = int(input())
for _ in range(t):
	l = []
	arr = list(map(int, input().strip().split()))
	n = arr[0]
	k = arr[1]
	need = math.floor((k - 1) / (n - 1))
	print(need + k)


t = int(input())
for tc in range(t):
	s = input().split()
	(n, k) = (int(s[0]), int(s[1]))
	q = k // (n - 1)
	r = k % (n - 1)
	if r == 0:
		print(n * q - 1)
	else:
		print(n * q + r)


import math
from sys import stdin
input = stdin.readline
for _ in range(int(input())):
	(n, k) = [int(i) for i in input().split()]
	c = k - (n - 1) * (k // (n - 1))
	if c == 0:
		c = -1
	print(n * (k // (n - 1)) + c)


import math
t = int(input(''))
while t > 0:
	sum = 0
	(n, k) = map(int, input().split())
	sum = k // (n - 1) * n + k % (n - 1)
	if k % (n - 1) == 0:
		print(sum - 1)
	else:
		print(sum)
	t -= 1


t = int(input())
q = 0
for _ in range(t):
	(n, k) = map(int, input().split())
	q = (k - 1) * n // (n - 1) + 1
	print(q)
	q = 0


import math
for _ in range(int(input())):
	(n, k) = map(int, input().split())
	if n > k:
		print(k)
	else:
		print(k + math.ceil(k / (n - 1)) - 1)


class A:

	def solve(self):
		t = int(input())
		for i in range(t):
			n = list(map(int, input()))
			round_numbers = list(map(lambda x: x[0] * 10 ** x[1], filter(lambda x: x[0] > 0, zip(n, reversed(list(range(len(n))))))))
			print(len(round_numbers))
			print(' '.join(map(str, round_numbers)))

class B:

	def solve(self):
		t = int(input())
		for p in range(t):
			in_list = list(map(int, input().split(' ')))
			(n, k) = (in_list[0], in_list[1])
			if k % 2 == 1:
				if n % 2 == 0:
					first_term = n - (k - 1) * 2
					if first_term <= 0:
						print('NO')
						continue
					print('YES')
					print(' '.join([str(first_term)] + ['2' for x in range(k - 1)]))
				else:
					first_term = n - (k - 1)
					if first_term <= 0:
						print('NO')
						continue
					print('YES')
					print(' '.join([str(first_term)] + ['1' for x in range(k - 1)]))
			elif n % 2 == 0:
				first_term = n - (k - 1)
				if first_term <= 0:
					print('NO')
					continue
				if first_term % 2 == 1:
					print('YES')
					print(' '.join([str(first_term)] + ['1' for x in range(k - 1)]))
					continue
				first_term = n - (k - 1) * 2
				if first_term <= 0:
					print('NO')
					continue
				if first_term % 2 == 0:
					print('YES')
					print(' '.join([str(first_term)] + ['2' for x in range(k - 1)]))
				else:
					print('NO')
			else:
				print('NO')

class C:

	def solve(self):
		t = int(input())
		for p in range(t):
			in_list = list(map(int, input().split(' ')))
			(n, k) = (in_list[0], in_list[1])
			m = k // (n - 1)
			if k % (n - 1) == 0:
				print(m * n - 1)
				continue
			print(m * n + k % (n - 1))
C().solve()


T = int(input())
for _ in range(T):
	(N, K) = map(int, input().split())
	(d, m) = divmod(K, N - 1)
	a = N * d
	if m:
		a += m
	else:
		a -= 1
	print(a)


for tc in range(int(input())):
	(n, k) = [int(s) for s in input().split()]
	k -= 1
	print(k // (n - 1) * n + k % (n - 1) + 1)


T = int(input())
for i in range(T):
	(n, k) = map(int, input().split())
	ans = 0
	a = k // (n - 1)
	r = a * n
	mo = k % (n - 1)
	if mo == 0:
		mo = -1
	ans = r + mo
	print(ans)


for t in range(int(input())):
	(n, k) = map(int, input().split())
	if k < n:
		print(k)
	elif k >= n:
		f = k % (n - 1)
		d = k // (n - 1)
		if k % (n - 1) == 0:
			print(n * d + f - 1)
		else:
			print(n * d + f)


import os
import sys
from io import BytesIO, IOBase
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
input = lambda : sys.stdin.readline().rstrip('\r\n')
import math

def fact(x):
	if x == 0:
		return 1
	else:
		return x * fact(x - 1)

def lower_bound(li, num):
	answer = -1
	start = 0
	end = len(li) - 1
	while start <= end:
		middle = (end + start) // 2
		if li[middle] >= num:
			answer = middle
			end = middle - 1
		else:
			start = middle + 1
	return answer

def upper_bound(li, num):
	answer = -1
	start = 0
	end = len(li) - 1
	while start <= end:
		middle = (end + start) // 2
		if li[middle] <= num:
			answer = middle
			start = middle + 1
		else:
			end = middle - 1
	return answer

def binary_search(lb, ub, val, cnt):
	mid = (lb + ub) // 2
	if val < mid:
		ub = mid - 1
		binary_search(lb, ub, val, cnt - 1)
	elif val > mid:
		lb = mid + 1
		binary_search(lb, ub, val, cnt - 1)
	else:
		print(cnt)

def abs(x):
	return x if x >= 0 else -x
for t in range(int(input())):
	(n, k) = list(map(int, input().split()))
	if k % (n - 1) != 0:
		ans = k // (n - 1) * n + k % (n - 1)
	else:
		ans = k // (n - 1) * n - 1
	print(ans)


t = int(input())
while t > 0:
	t -= 1
	(n, k) = [int(i) for i in input().split()]
	c = k + (k - 1) // (n - 1)
	print(c)


import math
for _ in range(int(input())):
	(n, k) = map(int, input().split())
	interval = math.ceil(k / (n - 1)) - 1
	num = interval * n + (k - (n - 1) * interval)
	print(num)


import sys
from collections import defaultdict
import random
import math
t = int(input())
for _ in range(t):
	(n, k) = map(int, input().split())
	d = n - 1
	x = k // d
	z = x * n
	a = k % d
	if a == 0:
		print(z - 1)
	else:
		print(a + z)


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


t = int(input())
for i in range(t):
	(n, k) = [int(x) for x in input().split()]
	non_div_per_n = n - 1
	qnt = k // non_div_per_n
	ajuste = -1 if k % non_div_per_n == 0 else k % non_div_per_n
	valor_final = qnt * n + ajuste
	print(valor_final)


for _ in range(int(input())):
	(n, k) = [int(s) for s in input().split()]
	x = n - 1
	r = int(k % x)
	d = k // x
	ans = n * d + r
	if r == 0:
		ans -= 1
	print(ans)


import os
import sys
from io import BytesIO, IOBase
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
input = lambda : sys.stdin.readline().rstrip('\r\n')
t = int(input())
for _ in range(t):
	(a, b) = map(int, input().split(' '))
	if b % (a - 1) == 0:
		print(b // (a - 1) * a - 1)
	else:
		print(b // (a - 1) * a + b % (a - 1))


t = int(input())
for i in range(t):
	(n, k) = map(int, input().split())
	rem = n - 1
	a = k / rem
	b = int(a)
	cl = n * b
	if a.is_integer():
		result = cl - 1
		print(result)
	else:
		g = rem * b
		r = k - g
		print(cl + r)


t = int(input())
ans = []
for _ in range(t):
	(n, k) = map(int, input().split())
	t = n * (k // (n - 1)) + k % (n - 1)
	ans.append(t if k % (n - 1) else t - 1)
print(*ans, sep='\n')


from math import ceil
from math import floor
from math import sqrt
from math import log

def mod_expo(n, p, m):
	result = 1
	while p != 0:
		if p % 2 == 1:
			result = result * n % m
		p //= 2
		n = n * n % m
	return result

def find_undev(n, k):
	if k % (n - 1) == 0:
		return int(n * k / (n - 1) - 1)
	return floor(n * k / (n - 1))
t = 1
t = int(input())
while t:
	t = t - 1
	count = 0
	(n, k) = map(int, input().split())
	arr = []
	b = []
	print(find_undev(n, k))


t = int(input())
for i in range(t):
	(k, n) = map(int, input().split())
	s = n
	while s - s // k < n:
		s += n - (s - s // k)
	print(s)


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


t = input()
for _ in range(int(t)):
	(n, k) = map(int, input().split())
	if k < n:
		print(k)
	else:
		ans = k - 1
		ans += (k + n - 2) // (n - 1)
		print(ans)


t = int(input())
for _ in range(t):
	(n, k) = map(int, input().split())
	q = k // (n - 1)
	r = k % (n - 1)
	if r == 0:
		print(q * n - 1)
	else:
		print(q * n + r)


t = int(input())
for _ in range(t):
	(n, k) = map(int, input().split())
	(a, b) = divmod(k, n - 1)
	if b == 0:
		print(a * n - 1)
	else:
		print(a * n + b)


import sys
t = int(input())
for _ in range(t):
	arr = input().split(' ')
	n = int(arr[0])
	k = int(arr[1])
	num = int(k / (n - 1)) * n + k % (n - 1)
	if num % n == 0:
		num -= 1
	print(num)


from math import ceil
for T in range(int(input())):
	(n, k) = list(map(int, input().split()))
	rep = ceil(k / (n - 1)) - 1
	ans = rep * (n - 1) + (k - rep * (n - 1)) + rep
	print(ans)


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


t = int(input())
for _ in range(t):
	(n, k) = map(int, input().split())
	va = k // (n - 1)
	var = k % (n - 1)
	if var == 0:
		print(n * va - 1)
	else:
		print(n * va + var)


def solve(n, k):
	cur = 1
	k -= 1
	t = k // (n - 1)
	cur = cur + n * t
	k = k - (n - 1) * t
	return cur + k
t = int(input())
for i in range(0, t):
	(n, k) = map(int, input().split())
	print(solve(n, k))


for x in range(int(input())):
	(dzielnik, liczba) = map(int, input().split())
	poprz = 0
	while True:
		wynik = liczba // dzielnik - poprz
		if wynik == 0:
			break
		liczba += wynik
		poprz += wynik
	print(liczba)


from sys import stdout, stdin
(_input, _print) = (stdin.buffer.readline, stdout.write)
(_int, _range) = (int, range)

def solution():
	for _ in _range(_int(_input())):
		(n, k) = [_int(i) for i in _input().split()]
		if k < n:
			print(k)
			continue
		start = k // (n - 1)
		if k % (n - 1) == 0:
			print(start * n - 1)
		else:
			print(start * n + k % (n - 1))
solution()


cases = int(input())
for t in range(cases):
	(n, k) = list(map(int, input().split()))
	x = k / (n - 1)
	if x == int(x):
		x -= 1
	x = int(x)
	print(k + x)


t = int(input())
while t:
	(n, k) = map(int, input().split())
	if k % (n - 1) == 0:
		print(n * (k // (n - 1) - 1) + n - 1)
	else:
		print(n * (k // (n - 1)) + k % (n - 1))
	t -= 1


import sys
import math
input = sys.stdin.readline

def int_array():
	return list(map(int, input().strip().split()))

def str_array():
	return input().strip().split()

def lower_letters():
	lowercase = [chr(i) for i in range(97, 97 + 26)]
	return lowercase

def upper_letters():
	uppercase = [chr(i) for i in range(65, 65 + 26)]
	return uppercase
for i in range(int(input())):
	(n, k) = int_array()
	row = k // (n - 1) * n
	if k % (n - 1) == 0:
		row -= 1
	else:
		row += k % (n - 1)
	print(row)


for _ in range(int(input())):
	(n, k) = map(int, input().split())
	z = k // (n - 1)
	if k % (n - 1) != 0:
		z += 1
	m = z * n
	z *= n
	t = z // n
	z -= t
	m -= 1
	print(m - (z - k))


N = int(input())
for _ in range(N):
	(n, k) = map(int, input().split())
	if k == 1:
		print(1)
		continue
	numsets = k // (n - 1)
	rem = k % (n - 1)
	if rem == 0:
		rem = -1
	counttilnumsets = numsets * n + rem
	print(counttilnumsets)


t = int(input())
for _ in range(t):
	(n, k) = [int(x) for x in input().split()]
	p = k // (n - 1)
	num = n * p
	if k % (n - 1) > 0:
		print(num + k % (n - 1))
	else:
		print(num - 1)


for _ in range(int(input())):
	(n, k) = map(int, input().split())
	if k < n:
		print(k)
	else:
		val1 = k // (n - 1)
		val2 = n * val1
		if k % (n - 1) == 0:
			print(val2 - 1)
		else:
			print(val2 + k % (n - 1))


I = lambda : list(map(int, input().split()))
(t,) = I()
for _ in range(t):
	(n, k) = I()
	x = k // (n - 1)
	y = k % (n - 1)
	print(x * n + (y if y != 0 else -1))


t = int(input())
s = ''
while t > 0:
	(n, k) = map(int, input().split())
	if n > k:
		s += str(k) + '\n'
	else:
		p = k
		k += int(k / n)
		while True:
			if int(k / n) - int(p / n) <= 0:
				break
			temp = k
			k += int(k / n) - int(p / n)
			p = temp
		s += str(k) + '\n'
	t -= 1
print(s)


for _ in range(int(input())):
	(n, m) = map(int, input().split())
	a = n - 1
	k = m % a
	b = m // a
	z = 0
	if k != 0:
		z = a * b + b
		z += k
	else:
		z = a * b + (b - 1)
	print(z)


t = int(input())
while t > 0:
	(n, k) = map(int, input().split())
	res = 0
	r = k % (n - 1)
	q = k // (n - 1)
	if r == 0:
		res = n * q - 1
	else:
		res = n * q + r
	print(res)
	t -= 1


from collections import *
from bisect import *
from math import *
import sys
input = sys.stdin.readline
t = int(input())
while t:
	t -= 1
	s = 0
	(n, k) = map(int, input().split())
	while 1:
		q = k // n
		s += q * n
		k -= q * n - q
		if k < n:
			break
	print(s + k)


import math, sys
t = int(input())
for _ in range(t):
	(n, k) = map(int, input().split())
	if k < n:
		print(k)
	else:
		x = k / (n - 1)
		y = int(x)
		if x > y:
			y = y + 1
		print(k - n * (y - 1) + y - 1 + n * y - n)


import math
for p in range(0, int(input())):
	b = input().split(' ')
	n = int(b[0])
	k = int(b[1])
	r = k / (n - 1)
	if k % (n - 1) == 0:
		print(int(n * r) - 1)
	else:
		print(int(n * r))


s = []
for jjk in range(int(input())):
	(n, k) = map(int, input().split())
	x = (k - 1) // (n - 1)
	x += 1
	y = (n - 1) * x + 1 - k
	s.append(n * x - y)
for i in s:
	print(i)


from sys import stdin, stdout

def main():
	lines = stdin.readlines()
	cas = lines[0]
	for line in lines[1:]:
		(n, k) = map(int, line.split(' '))
		fact = k // (n - 1)
		ini = n * fact
		cnt = ini - fact
		if cnt == k:
			res = ini - 1
		else:
			res = ini + (k - cnt)
		stdout.write(str(res))
		stdout.write('\n')
main()


import math
t = int(input())
for i in range(t):
	(n, k) = map(int, input().split())
	a = k + math.ceil(k / (n - 1)) - 1
	print(a)


t = int(input())
for i in range(t):
	nk = list(map(int, input().split()))
	n = nk[0]
	k = nk[1]
	if k % (n - 1) == 0:
		print(k // (n - 1) * n - 1)
	else:
		print(k // (n - 1) * n + k % (n - 1))


def solve(n, k):
	b = n * int(k / (n - 1))
	if k % (n - 1) == 0:
		print(int(b - 1 + k % (n - 1)))
	else:
		print(b + k % (n - 1))
t = int(input())
for _ in range(t):
	(n, k) = list(map(int, input().split()))
	solve(n, k)


t = int(input())
for test in range(t):
	(n, k) = map(int, input().split())
	a = 0
	b = 2 * k
	while b - a > 1:
		m = (a + b) // 2
		num = m - m // n
		if num < k:
			a = m
		else:
			b = m
	print(a if a - a // n == k else b)


def solve(n, k):
	if k // (n - 1) == k / (n - 1):
		return k // (n - 1) * n - 1
	else:
		return k // (n - 1) * n + k % (n - 1)
for j in range(int(input())):
	(n, k) = map(int, input().split())
	print(solve(n, k))


t = int(input())
for i in range(t):
	a = list(map(int, input().split()))
	k = a[0] * a[1] // (a[0] - 1)
	if k % a[0] == 0:
		print(k - 1)
	else:
		print(k)


for _ in range(int(input())):
	(n, k) = input().split()
	n = int(n)
	k = int(k)
	ans = 0
	q = k // (n - 1)
	p = k % (n - 1)
	if p != 0:
		ans = int(n * q + p)
	else:
		ans = int(n * q - 1)
	print(ans)


import sys
import os
import math
import copy
from math import gcd
from bisect import bisect
from io import BytesIO, IOBase
from math import sqrt, floor, factorial, gcd, log, ceil
from collections import deque, Counter, defaultdict
from itertools import permutations, combinations
import itertools

def Int():
	return int(sys.stdin.readline())

def Mint():
	return map(int, sys.stdin.readline().split())

def Lstr():
	return list(sys.stdin.readline().strip())

def Str():
	return sys.stdin.readline().strip()

def Mstr():
	return map(str, sys.stdin.readline().strip().split())

def List():
	return list(map(int, sys.stdin.readline().split()))

def Hash():
	return dict()

def Mod():
	return 1000000007

def Ncr(n, r, p):
	return fact[n] * (ifact[r] * ifact[n - r] % p) % p

def Most_frequent(list):
	return max(set(list), key=list.count)

def Mat2x2(n):
	return [List() for _ in range(n)]

def Lcm(x, y):
	lcm = x * y // gcd(x, y)
	return lcm

def solution():
	for i in range(Int()):
		(n, k) = Mint()
		ans = (k - 1) // (n - 1)
		print(ans + k)
solution()


def sol(n, k):
	if n > k:
		return print(k)
	elif n == k:
		return print(k + 1)
	else:
		d = n - 1
		v = k // d
		if k % d != 0:
			r = n * v + k % d
		else:
			r = n * v - 1
		return print(r)
t = int(input())
for _ in range(t):
	(n, k) = list(map(int, input().split()))
	sol(n, k)


n = int(input())
k = 0
l = []
while k <= n - 1:
	xx = [int(i) for i in input().split()]
	l.append(xx)
	k += 1
for t in l:
	a = t[0]
	b = t[1]
	if b % (a - 1) == 0:
		c = b % (a - 1) + int(b / (a - 1)) * a - 1
	else:
		c = b % (a - 1) + int(b / (a - 1)) * a
	print(str(c))


import math
from collections import Counter

def solve():
	(n, k) = map(int, input().split())
	if n > k:
		print(k)
		return
	elif n == k:
		print(k + 1)
	else:
		c = math.ceil(k / (n - 1))
		x = n * (c - 1) + k - (n - 1) * (c - 1)
		print(x)
for _ in range(int(input())):
	solve()


import math
t = int(input())

def func(n):
	for j in range(n):
		(n, k) = map(int, input().split())
		a = k
		b = k + math.floor(k / n)
		c = 0
		while True:
			c = c + b
			b = math.floor(c / n) - math.floor(a / n)
			a = c
			if b == 0:
				break
		print(c)
func(t)


t = int(input())
for _ in range(t):
	(n, k) = list(map(int, input().split()))
	cycle = n - 1
	(d, r) = divmod(k, cycle)
	if r == 0:
		print((d - 1) * n + cycle)
	else:
		print(d * n + r)


from math import ceil
t = int(input())
for _ in range(t):
	(n, k) = map(int, input().split())
	if k < n:
		print(k)
	else:
		div = n - 1
		mult = ceil(k / div) - 1
		print(mult * n + (k - mult * div))


for _ in range(int(input())):
	(n, k) = map(int, input().split())
	if k < n:
		print(k)
	else:
		temp = k // (n - 1)
		x = temp * n
		y = k - temp * (n - 1)
		if k % (n - 1) == 0:
			print(x + y - 1)
		else:
			print(x + y)


def solve(n, k):
	q = k // (n - 1)
	r = k % (n - 1)
	if r == 0:
		print(q * n - 1)
	else:
		print(q * n + r)

def read():
	t = int(input())
	for i in range(t):
		(n, k) = list(map(int, input().strip().split()))
		solve(n, k)
read()


t = int(input())
for _ in range(t):
	(n, k) = map(int, input().split())
	diff = n - 1
	rem = k % diff
	k -= rem
	ans = n * int(k / diff) + (rem if rem else -1)
	print(ans)


import math
a = int(input())

def get(k, n):
	return k - k // n
for i in range(0, a):
	(n, k) = map(int, input().split())
	l = k * n // (n - 1)
	if get(l - 1, n) == k:
		print(l - 1)
	elif get(l, n) == k:
		print(l)
	elif get(l + 1, n) == k:
		print(l + 1)


t = int(input())
ans = []
for z in range(t):
	(n, k) = map(int, input().split())
	temp = n * (k // (n - 1))
	rem = k - (n - 1) * (k // (n - 1))
	if rem == 0:
		temp -= 1
	else:
		temp += rem
	ans.append(temp)
for i in ans:
	print(i)


t = int(input())
for i in range(t):
	(N, K) = [int(c) for c in input().split()]
	print(K + (K - 1) // (N - 1))


from math import ceil
t = int(input())
for i in range(t):
	(n, k) = [int(i) for i in input().split()]
	part_num = ceil(k / (n - 1))
	start = (part_num - 1) * n
	nums_before = (part_num - 1) * (n - 1)
	to_get = k - nums_before
	print(start + to_get)


import math
counter = int(input())
for i in range(counter):
	(n, k) = map(int, input().split())
	growthfactor = n - 1
	level = math.ceil(k / growthfactor)
	start = n * (level - 1) + 1
	currentk = growthfactor * (level - 1) + 1
	result = start + (k - currentk)
	print(result)


import sys
t = int(input())
for j in range(t):
	(n, k) = map(int, input().split())
	ans = int(k / (n - 1))
	ans = ans * n
	ans = ans + k % (n - 1)
	if ans % n == 0:
		print(ans - 1)
		continue
	print(ans)


def f(n, k):
	n = int(n)
	k = int(k)
	a = k // (n - 1) * n + k % (n - 1)
	if k % (n - 1) == 0:
		a = a - 1
	print(a)
for i in range(int(input())):
	[n, k] = input().split(' ')
	f(n, k)


t = int(input())
for hh in range(0, t):
	(n, k) = [int(x) for x in input().split()]
	if k < n:
		print(k)
	elif k == n:
		print(n + 1)
	elif n == 2:
		ans = 2 * (k - 1) + 1
		print(ans)
	else:
		lessthann = n - 1
		comp = k // lessthann
		ans = n * comp
		rem = k % lessthann
		if rem != 0:
			ans += rem
		else:
			ans -= 1
		print(ans)


t = int(input())
for asd in range(t):
	a = [int(x) for x in input().split()]
	n = a[0]
	k = a[1]
	d = k // (n - 1)
	r = k % (n - 1)
	if r == 0:
		print(n * d - 1)
	else:
		print(n * d + r)


import sys
try:
	sys.stdin = open('Input.txt', 'r')
	sys.stdout = open('Output.txt', 'w')
except:
	pass
input = sys.stdin.readline
for testCases in range(int(input())):
	(m, k) = map(int, input().split())
	if k / (m - 1) % 1 == 0:
		quo = k // (m - 1)
		mul = quo * m
		ans = mul - 1
	else:
		quo = k // (m - 1)
		mul = quo * m
		var = quo * (m - 1)
		add = k - var
		ans = mul + add
	print(ans)


import math

def getNum(n, k):
	times = k / (n - 1)
	whole = math.floor(times)
	part = times - whole
	trickyPart = round((n - 1) * part, 2)
	extra = whole - 1 if part == 0 else whole + math.ceil(trickyPart)
	num = (n - 1) * whole + extra
	return num
for _ in range(int(input())):
	(n, k) = map(int, input().split())
	print(getNum(n, k))


import sys
input = sys.stdin.readline
for _ in range(int(input())):
	(a, b) = map(int, input().split())
	print((a * b - 1) // (a - 1))


import math
t = int(input())
while t:
	(N, K) = [int(r) for r in input().split(' ')]
	ans = K + math.floor((K - 1) / (N - 1))
	print(ans)
	t -= 1


from sys import stdin, stdout
for _ in range(int(input())):
	(a, b) = map(int, input().split())
	c = a - 1
	print(b + b // c - (1 if b % c == 0 else 0))


import math
import sys
for i in range(int(input())):
	(n, k) = map(int, input().split())
	add = k % (n - 1)
	if add == 0:
		add = -1
	if k < n:
		print(k)
	else:
		print(n * (k // (n - 1)) + add)


import math
t = int(input())
while t > 0:
	(n, k) = [int(i) for i in input().split()]
	y = int(math.ceil(k / (n - 1)))
	x = y * n
	a = x - y
	b = x - 1
	i = k + (b - a)
	print(i)
	t -= 1


n = int(input())
for i in range(n):
	(n, k) = [int(i) for i in input().split()]
	num = k // (n - 1)
	ost = k % (n - 1)
	if not ost:
		ans = (n - 1) * num + num + ost - 1
	else:
		ans = (n - 1) * num + num + ost
	print(ans)


t = int(input())
for i in range(t):
	(n, k) = [int(s) for s in input().split()]
	if k % (n - 1) == 0:
		print(k + k // (n - 1) - 1)
	else:
		print(k + k // (n - 1))


import math as m
t = int(input())
for i in range(t):
	(n, k) = map(int, input().split())
	x = k / (n - 1)
	x = m.ceil(x)
	y = int(x * n)
	y -= 1
	z = int(x * (n - 1))
	p = int(z - k)
	print(y - p)


from sys import stdin, stdout

def solve(n, k):
	need = (k - 1) // (n - 1)
	stdout.write(f'{k + need}\n')
	return
t = int(stdin.readline())
for _ in range(t):
	(n, k) = map(int, stdin.readline().split())
	solve(n, k)


t = int(input())
for i in range(t):
	data = input().split()
	n = int(data[0])
	k = int(data[1])
	r = k // (n - 1)
	answer = n * r + k % (n - 1)
	if k % (n - 1) == 0:
		answer -= 1
	print(answer)


from math import floor
for _ in range(int(input())):
	(n, k) = map(int, input().split())
	set_size = n - 1
	num = floor(k / set_size) * n + k % set_size
	if k % set_size == 0:
		num -= 1
	print(num)


I = input
for _ in range(int(I())):
	(n, k) = map(int, I().split())
	d = n - 0 - 1
	x = k // d
	if k % d == 0:
		print(n * x - 1)
	else:
		print(n * x + (k - d * x))


from collections import defaultdict

def solve():
	(n, k) = map(int, input().split())
	t = k // (n - 1)
	if k % (n - 1) == 0:
		t = t * n - 1
	else:
		t = t * n + k % (n - 1)
	print(t)
for _ in range(int(input())):
	solve()


import math
T = int(input())
for _ in range(T):
	(N, K) = map(int, input().split())
	output = K % (N - 1) + math.ceil(K // (N - 1)) * N
	if K % (N - 1) == 0:
		output -= 1
	print(output)


import sys, os.path
if os.path.exists('input.txt'):
	sys.stdin = open('input.txt', 'r')
	sys.stdout = open('output.txt', 'w')
sys.setrecursionlimit(10 ** 5)

def II():
	return int(sys.stdin.readline())

def MI():
	return map(int, sys.stdin.readline().split())

def LI():
	return list(map(int, sys.stdin.readline().split()))

def solve():
	(n, k) = MI()
	a = k // (n - 1)
	b = k % (n - 1)
	if a > 0 and b != 0:
		print(n * a + b)
	elif a > 0 and b == 0:
		print(n * a - 1)
	else:
		print(b)
for _ in range(II()):
	solve()


for _ in range(int(input())):
	(n, k) = map(int, input().split())
	if k < n:
		print(k)
	elif k == n:
		print(k + 1)
	elif n == 2:
		print(n * k - 1)
	elif k % (n - 1) == 0:
		print(k // (n - 1) * n + k % (n - 1) - 1)
	else:
		print(k // (n - 1) * n + k % (n - 1))


def kno(n, k):
	return (k - 1) // (n - 1) + k
t = int(input())
for u in range(t):
	(a, b) = map(int, input().strip().split())
	print(kno(a, b))


import math

def task_3(n, k):
	if k < n:
		return k
	m = k % (n - 1) if k % (n - 1) else n - 1
	return (math.ceil(k / (n - 1)) - 1) * n + m
t = int(input())
for i in range(t):
	(n, k) = input().split()
	print(task_3(int(n), int(k)))


import math

def solve():
	(n, k) = map(int, input().split())
	print(k + (k - 1) // (n - 1))
for _ in range(int(input())):
	solve()


from collections import defaultdict
import sys, math
f = None
try:
	f = open('q1.input', 'r')
except IOError:
	f = sys.stdin
if 'xrange' in dir(__builtins__):
	range = xrange

def print_case_iterable(case_num, iterable):
	print('Case #{}: {}'.format(case_num, ' '.join(map(str, iterable))))

def print_case_number(case_num, iterable):
	print('Case #{}: {}'.format(case_num, iterable))

def print_iterable(A):
	print(' '.join(A))

def read_int():
	return int(f.readline().strip())

def read_int_array():
	return [int(x) for x in f.readline().strip().split(' ')]

def rns():
	a = [x for x in f.readline().split(' ')]
	return (int(a[0]), a[1].strip())

def read_string():
	return list(f.readline().strip())
NUMBER = 10 ** 9 + 7

def factorial(n):
	M = NUMBER
	f = 1
	for i in range(1, n + 1):
		f = f * i % M
	return f

def mult(a, b):
	return a * b % NUMBER

def minus(a, b):
	return (a - b) % NUMBER

def plus(a, b):
	return (a + b) % NUMBER

def egcd(a, b):
	if a == 0:
		return (b, 0, 1)
	else:
		(g, y, x) = egcd(b % a, a)
		return (g, x - b // a * y, y)

def modinv(a):
	m = NUMBER
	(g, x, y) = egcd(a, m)
	if g != 1:
		raise Exception('modular inverse does not exist')
	else:
		return x % m
from collections import deque, defaultdict
import heapq

def bfs(V, E):
	s = set()
	num_connected_components = 0
	for v in V:
		if v in s:
			continue
		q = deque([])
		s.add(v)
		q.append(v)
		while len(q) > 0:
			x = q.popleft()
			for e in E[x]:
				if e not in s:
					s.add(e)
					q.append(e)
		num_connected_components += 1
	return num_connected_components

def bfs_get_neig(V, get_neig):
	s = set()
	num_connected_components = 0
	for v in V:
		if v in s:
			continue
		q = deque([])
		s.add(v)
		q.append(v)
		while len(q) > 0:
			x = q.popleft()
			for e in get_neig(*x):
				if e not in s:
					s.add(e)
					q.append(e)
		num_connected_components += 1
	return num_connected_components

def binary_count_smaller(L, x):
	l = 0
	if x < L[0]:
		return 0
	r = len(L)
	while r - l > 1:
		mid = (l + r) // 2
		if L[mid] < x:
			l = mid
		else:
			r = mid
	return l + 1

def binary_count_larger(L, x):
	l = 0
	if x > L[-1]:
		return 0
	r = len(L)
	while r - l > 1:
		mid = (l + r) // 2
		if L[mid] <= x:
			l = mid
		else:
			r = mid
	return len(L) - (r - 1)

def regular_bs(L, x, l=None, r=None):
	l = 0 if l == None else l
	r = len(L) if r == None else r
	while r - l > 1:
		m = (r + l) // 2
		l = m if L[m] <= x else l
		r = m if L[m] > x else r
	cnt = 0
	return l
from itertools import product

def preprocess():
	nums = dict(zip(sequences, range(10)))
	changes = defaultdict(dict)
	for comb in map(lambda x: ''.join(x), product(*[['0', '1']] * 7)):
		for seq in sequences:
			a = int(comb, 2)
			b = int(seq, 2)
			num_changes = bin(a ^ b).count('1')
			if num_changes == seq.count('1') - comb.count('1'):
				changes[comb][num_changes] = nums[seq]
	return changes
from collections import deque
from itertools import product

def bi(x):
	return bin(x)[2:]

def check_no_ghg_row(matrix, n, m):
	for i in range(n):
		black = False
		white = False
		for x in matrix[i]:
			if x == '.' and (not black or white):
				continue
			if x == '#' and black and white:
				return False
			if x == '#' and black:
				continue
			if x == '.' and black:
				white = True
			if x == '#':
				black = True
	return True

def check_no_ghg_col(matrix, n, m):
	for j in range(m):
		black = False
		white = False
		for i in range(n):
			x = matrix[i][j]
			if x == '.' and (not black or white):
				continue
			if x == '#' and black and white:
				return False
			if x == '#' and black:
				continue
			if x == '.' and black:
				white = True
			if x == '#':
				black = True
	return True

def empty_col(matrix, n, m):
	for j in range(m):
		empty = True
		for i in range(n):
			if matrix[i][j] == '#':
				empty = False
				break
		if empty:
			return True
	return False

def empty_row(matrix, n, m):
	for i in range(n):
		empty = True
		for j in range(m):
			if matrix[i][j] == '#':
				empty = False
				break
		if empty:
			return True
	return False

def find_lcm(num1, num2):
	if num1 > num2:
		num = num1
		den = num2
	else:
		num = num2
		den = num1
	rem = num % den
	while rem != 0:
		num = den
		den = rem
		rem = num % den
	gcd = den
	lcm = int(int(num1 * num2) / int(gcd))
	return lcm

def find_lcm_array(A):
	if len(A) == 1:
		return A[0]
	lcm = find_lcm(A[0], A[1])
	for i in range(2, len(A)):
		lcm = find_lcm(lcm, A[i])
	return lcm

class TreeNode:

	def __init__(self, key, left=None, right=None):
		self.left = left if left else None
		self.right = right if right else None
		self.key = key

def solution(n, k):
	if k % (n - 1) == 0:
		return k // (n - 1) * n - 1
	return k // (n - 1) * n + k % (n - 1)

def prepare_squares():
	L = []
	for i in range(int(math.sqrt(10 ** 7)) + 1):
		L.append(i ** 2)
	return L

def main():
	squares = prepare_squares()
	T = read_int()
	for i in range(T):
		(n, k) = read_int_array()
		x = solution(n, k)
		if 'xrange' not in dir(__builtins__):
			print(x)
		else:
			(print >> output, str(x))
	if 'xrange' in dir(__builtins__):
		print(output.getvalue())
		output.close()
if 'xrange' in dir(__builtins__):
	import cStringIO
	output = cStringIO.StringIO()
main()


t = int(input())
for j in range(t):
	g = input()
	n = int(g.split()[0])
	k = int(g.split()[1])
	p = (k - 1) // (n - 1)
	print(k + p)


for _ in range(int(input())):
	(n, k) = map(int, input().split())
	rem = k % (n - 1)
	q = k // (n - 1)
	if rem == 0:
		print(q * n - 1)
	else:
		print(q * n + rem)


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


MOD = 10 ** 9 + 7
RLIMIT = 1000
DEBUG = 1

def main():
	for _ in inputt():
		(n, k) = inputi()
		k = (k - 1) // (n - 1) * n + (k - 1) % (n - 1) + 1
		print(k)
from math import *
from heapq import *
from itertools import *
from functools import reduce, lru_cache, partial
from collections import Counter, defaultdict
import re, copy, operator, cmath
import sys, io, os, builtins
sys.setrecursionlimit(RLIMIT)
BUFSIZE = 8192

class FastIO(io.IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = io.BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(io.IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')

def print(*args, **kwargs):
	if args:
		sys.stdout.write(str(args[0]))
		split = kwargs.pop('split', ' ')
		for arg in args[1:]:
			sys.stdout.write(split)
			sys.stdout.write(str(arg))
	sys.stdout.write(kwargs.pop('end', '\n'))

def debug(*args, **kwargs):
	if DEBUG and (not __debug__):
		print('debug', *args, **kwargs)
		sys.stdout.flush()
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
input = lambda : sys.stdin.readline().rstrip()
inputt = lambda t=0: range(t) if t else range(int(input()))
inputs = lambda : input().split()
inputi = lambda k=int: map(k, inputs())
inputl = lambda t=0, k=lambda : list(inputi()): [k() for _ in range(t)] if t else list(k())

def len(a):
	if isinstance(a, range):
		return -((a.start - a.stop) // a.step)
	return builtins.len(a)

def bisect_left(a, x, key=None, lo=0, hi=None):
	if lo < 0:
		lo = 0
	if hi == None:
		hi = len(a)
	if key == None:
		key = do_nothing
	while lo < hi:
		mid = (lo + hi) // 2
		if key(a[mid]) < x:
			lo = mid + 1
		else:
			hi = mid
	return lo

def bisect_right(a, x, key=None, lo=0, hi=None):
	if lo < 0:
		lo = 0
	if hi == None:
		hi = len(a)
	if key == None:
		key = do_nothing
	while lo < hi:
		mid = (lo + hi) // 2
		if x < key(a[mid]):
			hi = mid
		else:
			lo = mid + 1
	return lo

def insort_left(a, x, key=None, lo=0, hi=None):
	lo = bisect_left(a, x, key, lo, hi)
	a.insert(lo, x)

def insort_right(a, x, key=None, lo=0, hi=None):
	lo = bisect_right(a, x, key, lo, hi)
	a.insert(lo, x)
do_nothing = lambda x: x
bisect = bisect_right
insort = insort_right

def index(a, x, default=None, key=None, lo=0, hi=None):
	if lo < 0:
		lo = 0
	if hi == None:
		hi = len(a)
	if key == None:
		key = do_nothing
	i = bisect_left(a, x, key, lo, hi)
	if lo <= i < hi and key(a[i]) == x:
		return a[i]
	if default != None:
		return default
	raise ValueError

def find_lt(a, x, default=None, key=None, lo=0, hi=None):
	if lo < 0:
		lo = 0
	if hi == None:
		hi = len(a)
	i = bisect_left(a, x, key, lo, hi)
	if lo < i <= hi:
		return a[i - 1]
	if default != None:
		return default
	raise ValueError

def find_le(a, x, default=None, key=None, lo=0, hi=None):
	if lo < 0:
		lo = 0
	if hi == None:
		hi = len(a)
	i = bisect_right(a, x, key, lo, hi)
	if lo < i <= hi:
		return a[i - 1]
	if default != None:
		return default
	raise ValueError

def find_gt(a, x, default=None, key=None, lo=0, hi=None):
	if lo < 0:
		lo = 0
	if hi == None:
		hi = len(a)
	i = bisect_right(a, x, key, lo, hi)
	if lo <= i < hi:
		return a[i]
	if default != None:
		return default
	raise ValueError

def find_ge(a, x, default=None, key=None, lo=0, hi=None):
	if lo < 0:
		lo = 0
	if hi == None:
		hi = len(a)
	i = bisect_left(a, x, key, lo, hi)
	if lo <= i < hi:
		return a[i]
	if default != None:
		return default
	raise ValueError

class Tree:

	def __init__(n):
		self._n = n
		self._conn = [[] for _ in range(n)]
		self._list = [0] * n

	def connect(a, b):
		pass

class Sieve:

	def __init__(self):
		self._n = 6
		self._list = [2, 3, 5, 7, 11, 13]

	def extend(self, n):
		if n <= self._list[-1]:
			return
		maxbase = int(n ** 0.5) + 1
		self.extend(maxbase)
		begin = self._list[-1] + 1
		newsieve = [i for i in range(begin, n + 1)]
		for p in self.primerange(2, maxbase):
			for i in range(-begin % p, len(newsieve), p):
				newsieve[i] = 0
		self._list.extend([x for x in newsieve if x])

	def extend_to_no(self, i):
		while len(self._list) < i:
			self.extend(int(self._list[-1] * 1.5))

	def primerange(self, a, b):
		a = max(2, a)
		if a >= b:
			return
		self.extend(b)
		i = self.search(a)[1]
		maxi = len(self._list) + 1
		while i < maxi:
			p = self._list[i - 1]
			if p < b:
				yield p
				i += 1
			else:
				return

	def search(self, n):
		if n < 2:
			raise ValueError
		if n > self._list[-1]:
			self.extend(n)
		b = bisect(self._list, n)
		if self._list[b - 1] == n:
			return (b, b)
		else:
			return (b, b + 1)

	def __contains__(self, n):
		if n < 2:
			raise ValueError
		if not n % 2:
			return n == 2
		(a, b) = self.search(n)
		return a == b

	def __getitem__(self, n):
		if isinstance(n, slice):
			self.extend_to_no(n.stop + 1)
			return self._list[n.start:n.stop:n.step]
		else:
			self.extend_to_no(n + 1)
			return self._list[n]
sieve = Sieve()

def isprime(n):
	if n <= sieve._list[-1]:
		return n in sieve
	for i in sieve:
		if not n % i:
			return False
		if n < i * i:
			return True
prime = sieve.__getitem__
primerange = lambda a, b=0: sieve.primerange(a, b) if b else sieve.primerange(2, a)

def factorint(n):
	factors = []
	for i in sieve:
		if n < i * i:
			break
		while not n % i:
			factors.append(i)
			n //= i
	if n != 1:
		factors.append(n)
	return factors
factordict = lambda n: Counter(factorint(n))
main()


t = int(input())
while t:
	t -= 1
	(n, k) = map(int, input().split())
	m = k // (n - 1)
	if k % (n - 1) == 0:
		ans = n * m - 1
	else:
		ans = n * m
		res = k % (n - 1)
		ans += res
	print(ans)


from collections import *
from itertools import *
from functools import *
import sys
import os
import time
timer = False
debug = False

def timeit(method):

	def wrapper(*args, **kwargs):
		mname = method.__name__
		if debug:
			print('{}(args:{}, kwargs:{})'.format(mname, args, kwargs))
		if timer:
			ts = time.time()
		result = method(*args, **kwargs)
		if timer:
			te = time.time()
			print('%r  %2.2f ms' % (mname, (te - ts) * 1000))
		return result
	return wrapper

def read_ints():
	return list(map(int, input().split()))

def read_floats():
	return list(map(float, input().split()))

def read_strs():
	return input().split()

@timeit
def main():
	t = int(input())
	for _ in range(t):
		(n, k) = read_ints()
		m = n - 1
		ans = k // m * n + k % m
		if k % m == 0:
			print(ans - 1)
		else:
			print(ans)
main()


cases = int(input())
for i in range(0, cases):
	(n, k) = map(int, input().split())
	result = (k - 1) // (n - 1)
	print(result + k)


def kthdiv(n, k):
	rem = n - 1
	add = k // rem
	if k % rem != 0:
		add += 1
		sub = rem * add - k
		ans = n * add - (sub + 1)
	else:
		sub = rem * add - k
		ans = n * add - (sub + 1)
	return ans
test = int(input())
for i in range(test):
	(n, k) = map(int, input().split())
	print(kthdiv(n, k))


tests = int(input())
while tests:
	(n, k) = [int(x) for x in input().split()]
	bucket = int((k - 1) / (n - 1))
	print(k + bucket)
	tests -= 1


t = int(input())
for _ in range(t):
	nk = input().split(' ')
	n = int(nk[0])
	k = int(nk[1])
	x = k // (n - 1)
	if (k + x) % n == 0:
		print(k + x - 1)
	else:
		print(k + x)


import sys

def get_array():
	return list(map(int, sys.stdin.readline().strip().split()))

def get_ints():
	return map(int, sys.stdin.readline().strip().split())

def input():
	return sys.stdin.readline().strip()
for _ in range(int(input())):
	(n, k) = map(int, input().split())
	j = k % (n - 1)
	p = k // (n - 1)
	if j == 0:
		ans = n * p - 1
		print(ans)
	else:
		ans = n * p + j
		print(ans)


def read_int():
	n = int(input())
	return n

def read_ints():
	ints = [int(x) for x in input().split(' ')]
	return ints

def solve(n, k):
	cntr = k // (n - 1)
	sol = cntr + k
	if sol % n == 0:
		sol -= 1
	return sol
t = read_int()
for case in range(t):
	(n, k) = read_ints()
	sol = solve(n, k)
	print(sol)


for t in range(int(input())):
	(n, k) = map(int, input().split())
	x = n * k // (n - 1)
	x -= x % n == 0
	print(x)


for t in range(int(input())):
	(n, k) = list(map(int, input().split()))
	d = k // (n - 1)
	r = k % (n - 1)
	if r == 0:
		ans = n * d - 1
	else:
		ans = n * d + r
	print(ans)


import math
t = int(input())
for i in range(t):
	(n, k) = map(int, input().split())
	if n == k:
		print(n + 1)
	else:
		print(math.ceil(k * n / (n - 1)) - 1)


def solve(n, k):
	return n * (k // (n - 1)) + k % (n - 1) - (1 if k % (n - 1) == 0 else 0)
cases = int(input())
for _ in range(cases):
	print(solve(*map(int, input().split())))


def f(x, y):
	if y % (x - 1) == 0:
		a = y // (x - 1)
		return x * a - 1
	elif y % (x - 1) != 0:
		a = y // (x - 1)
		b = y % (x - 1)
		return x * a + b
t = int(input())
for i in range(0, t):
	(n, k) = map(int, input().split())
	print(f(n, k))


import sys
input = sys.stdin.readline
t = int(input())
for tests in range(t):
	(n, k) = map(int, input().split())
	B = k // (n - 1) * n
	if k % (n - 1) == 0:
		print(B - 1)
	else:
		print(B + k % (n - 1))


t = int(input())
for _ in range(t):
	(n, k) = [int(i) for i in input().split()]
	new_k = k + k // n
	while new_k // n - k // n != 0:
		add = new_k // n - k // n
		k = new_k
		new_k += add
	print(new_k)


from sys import stdin, stdout
for testcases in range(int(stdin.readline())):
	(n, k) = map(int, stdin.readline().split())
	remainder = k % (n - 1)
	div = k // (n - 1)
	if remainder == 0:
		result = n * div - 1
	else:
		result = div * n + remainder
	stdout.write(str(result) + '\n')


import math
k = int(input())
a = []
for i in range(0, k):
	(num1, num2) = [int(x) for x in input().split()]
	a.append([num1, num2])
for i in a:
	(divider, quantity) = i
	last_num = divider * math.ceil(quantity / (divider - 1)) - 1
	index_of_last = math.ceil(quantity / (divider - 1)) * (divider - 1)
	result = last_num - (index_of_last - quantity)
	print(result)


import math
a = int(input(''))
for i in range(a):
	dat = list(map(int, input('').split()))
	x = math.ceil(dat[1] / (dat[0] - 1))
	print(str(dat[1] + x - 1))


t = int(input())
for i in range(t):
	(n, k) = map(int, input().split())
	loop = (k + n - 2) // (n - 1)
	if k % (n - 1) == 0:
		print(n * (loop - 1) + n - 1)
	else:
		print(n * (loop - 1) + k % (n - 1))


import math

def delsfrom(a, b, delim):
	return delfromzero(b, delim) - delfromzero(a, delim)

def delfromzero(a, delim):
	return a // delim
for _ in range(int(input())):
	(n, k) = map(int, input().split())
	prev = k
	a = delfromzero(prev, n)
	next = prev + a
	s = a
	while a > 0:
		a = delsfrom(prev, next, n)
		prev = next
		next = prev + a
		s += a
	print(k + s)


t = int(input())
for _ in range(t):
	(n, k) = map(int, input().split())
	mul = k // (n - 1)
	rem = k % (n - 1)
	if k % (n - 1) == 0:
		print(mul * n + rem - 1)
	else:
		print(mul * n + rem)


for i in range(int(input())):
	(n, k) = map(int, input().split())
	r = k % (n - 1)
	q = k // (n - 1)
	if r == 0:
		print(n * q - 1)
	elif r > 0:
		print(n * q + r)


from collections import defaultdict
for _ in range(int(input())):
	(n, k) = map(int, input().split())
	print((n * k - 1) // (n - 1))


import sys
import collections
input = sys.stdin.readline
t = int(input())
values = []
for i in range(t):
	(n, k) = list(map(int, input().split(' ')))
	values.append((n, k))
for (n, k) in values:
	r = k + (k - 1) / (n - 1)
	print(int(r))


t = int(input())
count = 0
while count < t:
	count += 1
	l = list(map(int, input().split(' ')))
	n = l[0]
	k = l[1]
	if k < n:
		print(k)
	elif k == n:
		print(k + 1)
	else:
		mul = k // (n - 1)
		zoom = n * mul
		if k % (n - 1) == 0:
			print(zoom - 1)
		else:
			zoom += k % (n - 1)
			print(zoom)


import math
num = int(input())
for i in range(num):
	(n, k) = [int(l) for l in input().split(' ')]
	a1 = math.floor(k / (n - 1))
	a2 = math.floor(k % (n - 1))
	ans = a1 * n + a2
	if a2 == 0:
		ans -= 1
	print(ans)


import math

def getNum(n, k):
	num = k + (k - 1) // (n - 1)
	return num
for _ in range(int(input())):
	(n, k) = map(int, input().split())
	print(getNum(n, k))


for _ in range(int(input())):
	(a, b) = map(int, input().split())
	inter = a - 1
	skip = b // inter
	start = a * skip
	left = b - inter * skip
	if left == 0:
		print(start - 1)
	else:
		print(left + start)


def result(start, end, q, n):
	q = end // n - q
	while q != 0:
		x = end // n
		start = end
		end = end + q
		return result(start, end, x, n)
	return end
t = int(input())
while t > 0:
	(n, k) = [int(x) for x in input().split()]
	if k >= n:
		print(result(0, k, 0, n))
	else:
		print(k)
	t -= 1


t = int(input())
for each in range(1, t + 1):
	(n, k) = input().split()
	ans = int(int(k) / (int(n) - 1)) * int(n)
	if int(k) % (int(n) - 1) == 0:
		ans -= 1
	else:
		ans += int(k) % (int(n) - 1)
	print(ans)


t = int(input())

def solve(n, k):
	ith = k - k // n
	diff = k - ith
	num = k
	while diff > 0:
		num += diff
		ith = num - num // n
		diff = k - ith
	return num
for _ in range(t):
	(n, k) = list(map(int, input().split()))
	print(solve(n, k))


import math
from sys import stdin, stdout
from heapq import heapify, heappop, heappush
from collections import Counter
T = int(stdin.readline())
for i in range(T):
	(n, k) = list(map(int, stdin.readline().split()))
	p = k // (n - 1) * n
	x = k // (n - 1)
	back = x * (n - 1)
	if back == k:
		print(p - 1)
	else:
		print(p + k - back)


import sys

def get_number(n, k):
	x = k // (n - 1)
	r = k % (n - 1)
	if not r:
		return x * n - 1
	else:
		return n * x + r
data = [i.strip() for i in sys.stdin.readlines()]
for i in range(len(data)):
	if i:
		(n, k) = [int(j) for j in data[i].split()]
		x = get_number(n, k)
		print(x)


for t in range(int(input())):
	(n, k) = map(int, input().split())
	if k < n:
		print(k)
	else:
		ad = k // n
		t = k + ad
		while 1:
			temp = t // n
			if temp - ad == 0:
				break
			else:
				t += temp - ad
				ad = temp
		if t % n == 0:
			print(t + 1)
		else:
			print(t)


from sys import stdout
for _ in range(int(input())):
	(n, k) = map(int, input().split())
	print(k + (k - 1) // (n - 1))


for i in range(int(input())):
	(n, k) = map(int, input().split())
	c1 = k % (n - 1)
	c2 = k // (n - 1)
	if c1 == 0:
		print(n * c2 - 1)
	elif c1 != 0:
		print(n * c2 + c1)


from collections import defaultdict, deque
from itertools import permutations
from sys import stdin, stdout
from bisect import bisect_left, bisect_right
from copy import deepcopy
import heapq
int_input = lambda : int(stdin.readline())
string_input = lambda : stdin.readline().split()
multi_int_input = lambda : map(int, stdin.readline().split())
multi_input = lambda : stdin.readline().split()
list_input = lambda : list(map(int, stdin.readline().split()))
string_list_input = lambda : list(string_input())
MOD = pow(10, 9) + 7
test = int_input()
for _ in range(test):
	(n, k) = multi_int_input()
	x = k // n
	s = a = k + x
	while s // n != x:
		s = s + (a // n - x)
		x = a // n
		a = s
	print(s)


from collections import Counter
import math
mod = 10 ** 9 + 7
for i in range(int(input())):
	(n, k) = map(int, input().split())
	a = n
	xa = math.ceil(k / (n - 1))
	ya = 1 + (xa - 1) * a
	ans = (xa - 1) * (a - 1)
	ans += 1
	ans = k - ans
	ans += ya
	print(ans)


Ntc = int(input())

def getKCount(k, gap):
	res = k / gap
	if not res.is_integer():
		res = int(res) + 1
	else:
		res = int(res)
	return res
for _ in range(Ntc):
	(n, k) = map(int, input().split(' '))
	gap_space = n - 1
	k_count = getKCount(k, gap_space) - 1
	previous_divisible = n * k_count
	current_k = gap_space * k_count
	distance_to_ans = k - current_k
	print(distance_to_ans + previous_divisible)


import math

def inp():
	return int(input())

def inlist():
	return list(map(int, input().split()))

def instr():
	s = input()
	return list(s[:len(s)])

def invr():
	return map(int, input().split())
t = inp()
for _ in range(t):
	(n, k) = invr()
	res = k + (k - 1) // (n - 1)
	print(res)


t = int(input())
for _ in range(t):
	(n, k) = map(int, input().split())
	j = n - 1
	if k % j == 0:
		near = k // j
		ans = near * n - 1
		print(ans)
	else:
		near = k // j
		amari = k % j
		ans = near * n - 1
		ans += amari + 1
		print(ans)


def main():
	t = int(input())
	for __ in range(t):
		(k, curr) = map(int, input().split())
		last = 0
		while last // k != curr // k:
			temp = curr
			curr += curr // k - last // k
			last = temp
		print(curr)
main()


t = int(input())
for j in range(t):
	g = list(map(int, input().split()))
	n = g[0]
	k = g[1]
	if n > k:
		print(k)
	elif n == k:
		print(k + 1)
	else:
		a = k
		c = k
		d = 1
		while a != 1 and d != 0:
			b = a % n
			d = a // n
			a = d + b
			c += d
		print(c)


for _ in range(int(input())):
	(n, k) = [int(x) for x in input().split()]
	ans = n * (k // (n - 1)) + k % (n - 1)
	if k % (n - 1) == 0:
		ans -= 1
	print(ans)


def kth(n, k):
	return k + (k - 1) // (n - 1)
t = int(input())
for i in range(t):
	(n, k) = map(int, input().split())
	print(kth(n, k))


for _ in range(int(input())):
	(n, k) = map(int, input().split())
	x = n - 1
	floor = k // x
	if k % x != 0:
		print(n * floor + k % x)
	else:
		print(n * floor - 1)


t = int(input())
for _ in range(t):
	(n, k) = map(int, input().split())
	r = k % (n - 1)
	d = k // (n - 1)
	m = d * n
	c = 0
	if r == 0:
		print(m - 1)
	elif n == k:
		print(n + 1)
	else:
		print(c + r + m)


def solve(n, k, a, d):
	if a == 0:
		return k
	k += a
	a = k // n - d
	d = k // n
	return solve(n, k, a, d)
t = int(input())
for x in range(t):
	(n, k) = map(int, input().split())
	a = k // n
	d = k // n
	print(solve(n, k, a, d))


def sol():
	t = int(input())
	for _ in range(t):
		(k, n) = map(int, input().split())
		print(n + (n - 1) // (k - 1))
sol()


t = int(input())
for tt in range(t):
	(n, k) = map(int, input().split())
	sol = k // (n - 1) * n
	r = k % (n - 1)
	if r == 0:
		sol -= 1
	else:
		sol += r
	print(sol)


import math
t = int(input())
while t:
	t -= 1
	(n, k) = map(int, input().split())
	if k % (n - 1):
		i = k // (n - 1)
	else:
		i = k // (n - 1) - 1
	print(k + i)


import math
t = int(input())
for i in range(t):
	(n, k) = map(int, input().split())
	ans = k + math.floor((k - 1) / (n - 1))
	print(ans)


def kthNum(n, k):
	ans = k
	while ans - ans // n != k:
		temp = ans - ans // n
		if temp > k:
			ans -= temp - k
		elif temp < k:
			ans += k - temp
	return ans
for _ in range(int(input())):
	(n, k) = map(int, input().split())
	print(kthNum(n, k))


from sys import stdin, stdout
import math, sys
from itertools import permutations, combinations
from collections import defaultdict, deque, OrderedDict
import bisect as bi
import heapq

def I():
	return int(input())

def In():
	return map(int, input().split())

def main():
	try:
		(n, k) = In()
		if k % (n - 1) != 0:
			t = n * (k // (n - 1)) + k % (n - 1)
		else:
			t = n * (k // (n - 1)) + k % (n - 1) - 1
		print(t)
	except:
		pass
M = 998244353
P = 1000000007
for y in range(I()):
	main()


def findK(a, b):
	return b + (b - 1) // (a - 1)
query = int(input())
for i in range(query):
	array = list(map(int, input().split()))
	print(findK(array[0], array[1]))


t = int(input())

def search(t):
	l = 0
	r = len(a) - 1
	while r - l >= 0:
		mid = (l + r) // 2
		if a[mid] == t:
			return mid
		if a[mid] < t:
			l = mid + 1
		if a[mid] > t:
			r = mid - 1
	return mid

def f(a, d):
	return a - a // d
for _ in range(t):
	(n, k) = map(int, input().split())
	l = 0
	r = 1e+18
	ans = 1e+18
	while r - l >= 0:
		mid = (r + l) // 2
		if f(mid, n) < k:
			l = mid + 1
		if f(mid, n) >= k:
			r = mid - 1
			ans = mid
	print(int(ans))


def main():
	import sys, math
	from heapq import heapify, heappush, heappop
	from collections import defaultdict as dd, deque

	def data():
		return sys.stdin.readline().strip()

	def mdata():
		return list(map(int, data().split()))

	def out(*var, end='\n'):
		sys.stdout.write(' '.join(map(str, var)) + end)
	INF = int(1000000000.0)
	mod = int(1000000000.0) + 7
	for t in range(int(data())):
		(n, k) = mdata()
		a = k // (n - 1)
		if k % (n - 1) == 0:
			a -= 1
		ans = k + a
		print(ans)
main()


import io
import os
from collections import Counter, defaultdict, deque

def solve(N, K):
	lo = 0
	hi = 2 * K + 1

	def rank(n):
		return n - n // N
	assert rank(lo) < K <= rank(hi)
	while hi - lo > 1:
		mid = (lo + hi) // 2
		if rank(mid) < K:
			lo = mid
		else:
			hi = mid
		assert rank(lo) < K <= rank(hi)
	assert lo + 1 == hi
	assert rank(lo) < K <= rank(hi)
	return hi
input = io.BytesIO(os.read(0, os.fstat(0).st_size)).readline
T = int(input())
for t in range(T):
	(N, K) = [int(x) for x in input().split()]
	ans = solve(N, K)
	print(ans)


t = int(input())
while t:
	t -= 1
	(n, k) = map(int, input().split())
	rem = k % (n - 1)
	quos = k // (n - 1)
	if rem == 0:
		ans = (quos - 1) * n + (n - 1)
	else:
		ans = quos * n + rem
	print(ans)


tes = int(input())
for q in range(tes):
	a = input().split()
	(n, k) = (int(a[0]), int(a[1]))
	ans = k + (k - 1) // (n - 1)
	print(ans)


n = int(input())
for i in range(0, n):
	o = input().rstrip().split(' ')
	a = int(o[0])
	b = int(o[1])
	A = a - 1
	B = b // A
	C = b % A
	if C == 0:
		print(B * a - 1)
	else:
		D = B * a + C
		print(D)


def kth(n, k):
	if k < n:
		print(k)
		return
	p = n - 1
	a = (k - 1) // p
	print(k + a)
t = int(input())
for i in range(t):
	T = input()
	l = list(map(int, T.split()))
	kth(l[0], l[1])


def main():
	t = int(input())
	arr = []
	for i in range(t):
		arr.append(list(map(int, input().split())))
	for i in range(t):
		nthNumber(arr[i][0], arr[i][1])

def nthNumber(n, k):
	den = n - 1
	num = k - 1
	result = num // den
	print(k + result)
main()


def solve_eff(num, k):
	diff = (k - 1) // (num - 1)
	return k + diff
t = int(input())
while t > 0:
	nk = input().split()
	(number, kth) = (int(nk[0]), int(nk[1]))
	output = solve_eff(number, kth)
	print(output)
	t -= 1


t = int(input())
for i in range(t):
	(n, k) = [int(x) for x in input().split()]
	if n == 2:
		print(2 * k - 1)
	elif k < n:
		print(k)
	else:
		m = k % (n - 1)
		j = k // (n - 1)
		if m == 0:
			m = n - 1
			j -= 1
		print(j * n + m)


n = int(input())
for _ in range(n):
	(n, k) = [int(p) for p in input().split()]
	lower = k // (n - 1)
	num = (n - 1) * lower
	if num == k:
		print(lower * n - 1)
		continue
	k -= (n - 1) * lower
	s = lower * n
	print(s + k)


def f(n, k):
	n1 = n - 1
	if k < n:
		return k
	p = k // n1
	if k % n1:
		return k + p
	return k + p - 1
N = int(input())
for z in range(N):
	ss = input().split()
	(n, k) = [int(s) for s in ss]
	print(f(n, k))


for tests in range(int(input())):
	(n, k) = map(int, input().split())
	if k < n:
		print(k)
	elif k == n:
		print(n + 1)
	else:
		x = k
		t = (x - n) // n + 1
		a = [x]
		while 2 == 2:
			x = k + t
			t = (x - n) // n + 1
			a.append(x)
			if len(a) > 1 and a[-1] == a[-2]:
				break
		print(t + k)


for tc in range(int(input())):
	(n, k) = [int(x) for x in input().split()]
	(l, r) = (0, 10 ** 10)
	while l != r:
		mid = (l + r) // 2
		if mid * (n - 1) // n >= k:
			r = mid
		else:
			l = mid + 1
	print(l - 1)


for __ in range(int(input())):
	(n, k) = map(int, input().split())
	ans = n * (k // (n - 1)) + k % (n - 1)
	if k % (n - 1) == 0:
		ans -= 1
	print(ans)


a = int(input())
for ifei in range(a):
	vals = input().split()
	n = int(vals[0])
	k = int(vals[1])
	floor = n - 1
	num = k // floor
	extra = k % floor
	val = num * n
	if extra != 0:
		print(val + extra)
	else:
		print(val - 1)


def solve(n, k):
	loop = k // (n - 1)
	if k % (n - 1):
		return loop * n + (k - loop * (n - 1))
	else:
		return loop * n + (k - loop * (n - 1)) - 1
t = int(input())
for i in range(t):
	(n, k) = list(map(int, input().split()))
	ans = solve(n, k)
	print(ans)


for _ in range(int(input())):
	(n, k) = map(int, input().split())
	tmp = k
	former = 0
	while True:
		k = tmp + k // n
		if k // n == former:
			break
		former = k // n
	print(k)


def Find_index_k(n, k):
	index = k % (n - 1) != 0
	return k + k // (n - 1) - 1 + index
t = int(input())
for _ in range(t):
	(n, k) = map(int, input().split(' '))
	print(Find_index_k(n, k))


for _ in range(int(input())):
	(n, k) = map(int, input().split())
	fulls = k // (n - 1)
	par = k % (n - 1)
	if par == 0:
		par = -1
	print(fulls * n + par)


import math
t = int(input())
while t:
	(a, b) = list(map(int, input().split()))
	n = (b - 1) // (a - 1)
	print(b + n)
	t = t - 1


n = int(input())
for i in range(n):
	(q, w) = list(map(int, input().split(' ')))
	temp = int(w / (q - 1))
	total = 0
	if w % (q - 1) == 0:
		total = temp * q - 1
	else:
		total = temp * q + w % (q - 1)
	print(total)


t = int(input())
for i in range(t):
	(n, k) = map(int, input().split())
	k0 = k
	k1 = k
	k2 = k + k // n
	while k1 != k2:
		k0 = k1
		k1 = k2
		k2 += k1 // n - k0 // n
	print(k2)


from sys import stdin, stdout
import math

def main():
	t = int(stdin.readline())
	res = []
	for i in range(t):
		tc = stdin.readline().split(' ')
		n = int(tc[0])
		k = int(tc[1])
		res.append(math.floor(k / (n - 1)) * n + (k % (n - 1) if k % (n - 1) != 0 else -1))
	for s in res:
		print(s)
main()


import math
num = int(input())
for i in range(num):
	(n, k) = [int(l) for l in input().split(' ')]
	num1 = math.floor(k / (n - 1))
	num2 = math.floor(k % (n - 1))
	ans = num1 * n + num2
	if num2 == 0:
		ans -= 1
	print(ans)


t = int(input(''))
for i in range(t):
	[n, k] = list(map(int, input().split()))
	num = k * n // (n - 1)
	if num % n == 0:
		num -= 1
	print(num)


def notDiv(divisor, kthDiv, begin, end):
	half = (begin + end) // 2
	aux = half - half // divisor
	if begin > end:
		return begin
	if kthDiv <= aux:
		return notDiv(divisor, kthDiv, begin, half - 1)
	return notDiv(divisor, kthDiv, half + 1, end)
minimum = 1
maximum = 10000000000000
numTestCases = int(input())
for i in range(numTestCases):
	(n, k) = input().split()
	n = int(n)
	k = int(k)
	result = notDiv(n, k, minimum, maximum)
	print(result)


from collections import Counter as C, defaultdict as D, deque as Q
from operator import itemgetter as I
from itertools import product as P
from bisect import bisect_left as BL, bisect_right as BR
from heapq import heappush as HPUSH, heappop as HPOP
from math import floor as MF, ceil as MC, gcd as MG, factorial as F, sqrt as SQRT, inf as INFINITY, log as LOG
from sys import stdin, stdout
INPUT = stdin.readline
PRINT = stdout.write

def player1():
	print('')

def player2():
	print('')

def isPrime(n):
	for i in range(2, MC(SQRT(n)) + 1):
		if n % i == 0:
			return False
	return True

def factors(x):
	ans = []
	for i in range(1, MC(SQRT(x)) + 1):
		if x % i == 0:
			ans.append(i)
			if x % (x // i) == 0:
				ans.append(x // i)
	return ans

def main():
	for _ in range(int(INPUT())):
		(n, k) = map(int, INPUT().split())
		if k < n:
			PRINT(str(k) + '\n')
			continue
		if k == n:
			PRINT(str(n + 1) + '\n')
			continue
		m = MC((k - n + 1) / (n - 1))
		k -= (n - 1) * m
		start = n * m
		PRINT(str(start + k) + '\n')
main()


def interval(n, k):
	if k % (n - 1) != 0:
		return k // (n - 1) + 1
	elif k % (n - 1) == 0:
		return k // (n - 1)
T = int(input())
for j in range(T):
	(n, k) = map(int, input().split())
	gap = interval(n, k)
	print(gap - 1 + k)


for i in range(int(input())):
	(n, k) = map(int, input().split())
	a = [1, n - 1]
	t = k / (n - 1)
	if k == 1:
		print(1)
	elif t == int(t):
		print(n * int(t) - 1)
	elif k % (n - 1) == 0:
		print(n * (int(t) - 1))
	else:
		print(k % (n - 1) + n * int(t))


tq = int(input())
for q in range(tq):
	(n, q) = input().split()
	n = int(n)
	q = int(q)
	ans = q // (n - 1) * n
	ans += q % (n - 1)
	if ans % n == 0:
		ans -= 1
	print(ans)


def kthND(n, k):
	m = k // (n - 1)
	if k % (n - 1) == 0:
		m -= 1
	return m * n + (k - m * (n - 1))
t = int(input())
for i in range(t):
	a = input().split()
	n = int(a[0])
	k = int(a[1])
	print(kthND(n, k))


import math
t = int(input())
for _ in range(0, t):
	str1 = input()
	str1 = str1.split()
	n = int(str1[0])
	k = int(str1[1])
	if k % (n - 1) == 0:
		ans = k + (k // (n - 1) - 1)
	else:
		ans = k + k // (n - 1)
	print(ans)


def solve(n, k):
	if k < n:
		return k
	if k == n:
		return n + 1
	passed = (k - 1) // (n - 1)
	return k + passed

def main():
	t = int(input())
	for i in range(t):
		d = input()
		d = [int(i) for i in d.split()]
		n = int(d[0])
		a = int(d[1])
		ans = solve(n, a)
		print(ans)
main()


t = int(input())
results = []
for i in range(t):
	(n, k) = [int(x) for x in input().strip().split(' ')]
	if n > k:
		results.append(k)
		continue
	loop = n - 1
	how_many_loops = k // loop
	res = n * how_many_loops + k % loop
	if k % loop == 0:
		res -= 1
	results.append(res)
for r in results:
	print(r)


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


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


def f(x, y):
	l = 0
	r = y * y
	while r - l > 1:
		d = (l + r) // 2
		if d - d // x >= y:
			r = d
		else:
			l = d
	return r
t = int(input())
for i in range(t):
	(n, k) = map(int, input().split())
	print(f(n, k))


t = int(input())
while t > 0:
	t -= 1
	a = input().split()
	n = int(a[0])
	k = int(a[1])
	m = k // (n - 1)
	a = k % (n - 1)
	if a == 0:
		a = -1
	print(n * m + a)


import math
T = int(input())
for _ in range(0, T):
	(N, K) = list(map(int, input().split(' ')))
	mid = N - 1
	term = int(math.ceil(K / mid)) - 1
	idx = 0
	result = 0
	idx += N * term
	result += mid * term
	aterm = K - result
	print(idx + aterm)


from decimal import *
import math
caselist = []
cases = int(input())
for i in range(cases):
	(n, k) = input().split(' ')
	caselist.append((int(n), int(k)))
for nk in caselist:
	print(math.ceil(Decimal(nk[0]) * Decimal(nk[1]) / (Decimal(nk[0]) - 1)) - 1)


from math import ceil, floor
for _ in range(int(input())):
	(n, k) = map(int, input().split())
	if n == k:
		print(n + 1)
	elif k < n:
		print(k)
	else:
		m = ceil(k / (n - 1))
		x = n * (m - 1)
		k = k - (n - 1) * (m - 1)
		print(x + k)


import sys
input = sys.stdin.readline

def inp():
	return int(input())

def inlt():
	return list(map(int, input().split()))

def insr():
	s = input()
	return list(s[:len(s) - 1])

def invr():
	return map(int, input().split())
for _ in range(inp()):
	(n, k) = invr()
	a = 1 - 1 / n
	for i in range(int(k / a) - 1, int((k + 1) / a) + 1):
		if i - i // n == k:
			print(i)
			break


t = int(input())
for _ in range(t):
	(n, k) = map(int, input().split())
	if k % (n - 1) == 0:
		print(n - 1 + n * (k // (n - 1) - 1))
		continue
	print(k % (n - 1) + n * (k // (n - 1)))


t = int(input())
for _ in range(t):
	(n, k) = [int(i) for i in input().split()]
	step = n - 1
	res = k % step
	if res == 0:
		res -= 1
	print(n * (k // step) + res)


def solve(n, k):
	(l, r) = (1, 2 * 10 ** 9 + 5)
	sol = 0
	while l <= r:
		mid = l + (r - l) // 2
		if k == mid - mid // n:
			sol = mid
			r = mid - 1
		elif k < mid - mid // n:
			r = mid - 1
		else:
			l = mid + 1
	return sol
t = int(input())
for _ in range(t):
	(n, k) = map(int, input().split())
	print(solve(n, k))


import math
for T in range(int(input())):
	(n, k) = map(int, input().split())
	res = k + math.floor((k - 1) / (n - 1))
	print(res)


def solve_task(n, k):
	n = int(n)
	k = int(k)
	if k < n:
		return k
	m = n - 1
	nn = (k - 1) // m
	aa = nn * n
	res = aa + ((k - 1) % m + 1)
	return res

def main():
	n_test = int(input())
	solutions = []
	for nt in range(n_test):
		input_str = input()
		s = input_str.split()
		solutions.append(solve_task(s[0], s[1]))
	for s in solutions:
		print(s)
main()


def SameParitySummands():
	length = int(input())
	numData = [None for _ in range(length)]
	for i in range(length):
		numData[i] = input()
		numData[i] = numData[i].split(' ')
	result = []
	for elem in numData:
		base = int(elem[0])
		order = int(elem[1])
		it = order // (base - 1)
		if order // (base - 1) * (base - 1) != order:
			result.append(base * it + order - (base - 1) * it)
		else:
			result.append(base * it + order - (base - 1) * it - 1)
	for elem in result:
		print(elem)
SameParitySummands()


ans = []
for _ in range(int(input())):
	(n, k) = [int(x) for x in input().split()]
	ans.append(k + (k - 1) // (n - 1))
print('\n'.join(map(str, ans)))


from math import ceil
t = int(input())
for _ in range(t):
	(n, k) = map(int, input().split())
	if k < n:
		print(k)
		continue
	if k == n:
		print(n + 1)
		continue
	m = ceil(k / (n - 1))
	p_wyn = m * (n - 1)
	b = m * n
	print(b - (p_wyn - k + 1))


def answer(n, k):
	if k % (n - 1) == 0:
		x = k // (n - 1)
		return n * x - 1
	else:
		x = k // (n - 1)
		return n * x + k % (n - 1)
t = int(input())
for i in range(t):
	(n, k) = map(int, input().split())
	print(answer(n, k))


testCases = int(input())
while testCases > 0:
	(n, k) = map(int, input().split())
	answer = n * k // (n - 1)
	if answer % n == 0:
		answer -= 1
	print(answer)
	testCases -= 1


T = int(input())
while T:
	T -= 1
	(n, k) = map(int, input().split())
	t = k // (n - 1)
	r = k % (n - 1)
	print(t * n + r - bool(r == 0))


for _ in range(int(input())):
	(n, k) = map(int, input().split())
	val = k // n
	temp = k
	dif = val
	while True:
		temp = temp + dif
		if temp // n == val:
			break
		else:
			dif = abs(temp // n - val)
			val = temp // n
	print(temp)


def main():
	x = int(input())
	array = [str(input()).split() for _ in range(x)]
	for (n, k) in array:
		(n, k) = (int(n), int(k))
		var = k + (k - 1) // (n - 1)
		print(var)
main()


ans = []
for _ in range(int(input())):
	(n, k) = map(lambda i: int(i), input().split())
	ans.append(k + (k + (k - 1) // (n - 1)) // n)
for x in ans:
	print(x)


for t in range(int(input())):
	(n, k) = map(int, input().split())
	rem = k % (n - 1)
	qnt = k // (n - 1)
	if rem == 0:
		no = n * qnt - 1
	else:
		no = n * qnt + rem
	print(no)


from math import *
import sys
for i in range(int(sys.stdin.readline())):
	(n, k) = [int(x) for x in sys.stdin.readline().split()]
	print(int(ceil(k / (n - 1)) - 1) + k)


inp = input
li = list
iinp = lambda : int(inp())
ent = lambda : map(int, inp().split())
lient = lambda : [int(i) for i in inp().split()]
li0 = lambda x: [0 for i in range(x)]
livalor = lambda valor, x: [valor for i in range(x)]
stent = lambda : [i for i in inp()]
filldp = lambda valor, x, y: [[valor for i in range(y)] for i in range(x)]
l = len
t = iinp()
for _ in range(t):
	(n, k) = ent()
	nodivisibles = k + k // (n - 1)
	if nodivisibles % n == 0:
		nodivisibles = nodivisibles - 1
	print(nodivisibles)


def solve(time):
	(n, k) = [int(x) for x in input().split(' ')]
	(a, b) = divmod(k, n - 1)
	if b == 0:
		print(a * n - 1)
	else:
		print(b + a * n)
nums = int(input())
for _ in range(1, nums + 1):
	solve(_)


import math
for _ in range(int(input())):
	(n, k) = map(int, input().split())
	a = k // (n - 1)
	if k % (n - 1) != 0:
		print(n * a + k % (n - 1))
	else:
		print(n * a - 1)


def bs(n, k):
	(start, end, ret) = (0, 10 ** 9, -1)
	while start <= end:
		mid = start + end >> 1
		if mid * (n - 1) < k:
			ret = mid
			start = mid + 1
		else:
			end = mid - 1
	return ret * n
for _ in range(int(input())):
	(n, k) = map(int, input().split())
	pos = bs(n, k)
	print(k - (n - 1) * pos // n + pos)


t = int(input())
for i in range(t):
	(n, k) = map(int, input().split())
	k1 = k
	for i in range(100):
		k1 = k + k1 // n
	print(k1)


for _ in range(int(input())):
	(n, k) = map(int, input().split())
	m = k // (n - 1)
	r = k - (n - 1) * m
	if r == 0:
		print(n * m - 1)
	else:
		print(n * m + r)


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


t = int(input())
for _ in range(t):
	(n, k) = list(map(int, input().split()))
	c = k // (n - 1)
	last = k % (n - 1)
	if not last:
		result = n * c + last - 1
	else:
		result = n * c + last
	print(result)


GI = lambda : int(input())
GIS = lambda : map(int, input().split())
LGIS = lambda : list(GIS())

def main():
	for t in range(GI()):
		(n, k) = GIS()
		shift = k // n
		last_included = shift * n
		while True:
			rem = k + shift - last_included
			if rem < n:
				break
			shift += rem // n
			last_included = shift * n
		print(k + shift)
main()


for i in range(int(input())):
	(a, b, r, d, l, s) = (0, 0, 0, 0, [], [])
	(m, n) = map(int, input().split())
	a = n // m
	n = n + a
	while True:
		d = n // m
		b = d - a
		n = n + b
		if a == d:
			break
		a = d
	print(n)


t = int(input())
for i in range(t):
	(x, y) = map(int, input().split())
	p = (y - 1) // (x - 1)
	print(y + p)


import sys

def solve(n, k):
	num_div = int(k // (n - 1))
	y = int(k // (n - 1) * (n - 1) // k)
	print(k + num_div - y)

def main():
	n_cases = None
	for line in sys.stdin:
		if not n_cases:
			n_cases = line
			continue
		line = line.strip()
		line = line.rstrip()
		line = line.split(' ')
		n = int(line[0])
		k = int(line[1])
		solve(n, k)
main()


import sys
sys.setrecursionlimit(10 ** 5)
readline = sys.stdin.readline

def process():
	temp = list(map(int, readline().strip().split()))
	(n, k) = (temp[0], temp[1])
	if k % (n - 1) == 0:
		bucket = k // (n - 1)
		print(n * bucket - 1)
		return
	(bucket, left) = (k // (n - 1), k % (n - 1))
	lo = n * bucket + 1
	print(lo + left - 1)
for _ in range(int(readline())):
	process()


ans = []
for i in range(int(input())):
	(n, k) = map(int, input().split())
	ans.append(k + (k - 1) // (n - 1))
print(*ans, sep='\n')


def getKthNonDivisibleByN(n, k):
	p = n - 1
	mod = k % p
	d = k // p
	ans = d * n + mod
	if k % p == 0:
		ans = ans - 1
	return ans
tc = int(input())
for pos in range(tc):
	(n, k) = input().split(' ')
	(n, k) = [int(n), int(k)]
	print(getKthNonDivisibleByN(n, k))


from math import ceil
for q in range(int(input())):
	(n, k) = map(int, input().split())
	x = ceil(k / (n - 1))
	value = 1 + n * (x - 1)
	ind = (x - 1) * (n - 1) + 1
	print(value + (k - ind))


import math
t = int(input())
ans = []
for i in range(t):
	(m, k) = [int(x) for x in input().split()]
	a = math.ceil(k / (m - 1)) - 1
	b = k - (m - 1) * a
	ans.append(m * a + b)
print(*ans, sep='\n')


for _ in range(int(input())):
	(n, k) = list(map(int, input().split()))
	if k / (n - 1) * n // 1 == k / (n - 1) * n:
		print(int(k / (n - 1) * n // 1 - 1))
	else:
		print(int(k / (n - 1) * n) // 1)


import math
t = int(input())
for i in range(t):
	nk = list(map(int, input().split()))
	n = nk[0]
	k = nk[1]
	bucket = math.ceil(k / (n - 1))
	first = n * (bucket - 1) + 1
	index = (bucket - 1) * (n - 1) + 1
	shift = k - index
	answer = first + shift
	print(answer)


for _ in range(int(input())):
	(n, k) = map(int, input().split())
	(quo, remain) = (k // (n - 1), k % (n - 1))
	print(n * quo + (remain if remain != 0 else -1))


for __ in range(int(input())):
	(n, k) = map(int, input().split())
	c = n - 1
	d = int(k / c)
	e = n * d
	f = k % c
	if f != 0:
		print(e + f)
	else:
		print(e - 1)


t = int(input())
i = 0
while i < t:
	iterlist = [int(b) for b in input().split()]
	hue = iterlist[0] * (iterlist[1] // (iterlist[0] - 1)) + iterlist[1] % (iterlist[0] - 1)
	if iterlist[1] % (iterlist[0] - 1) == 0:
		print(hue - 1)
	else:
		print(hue)
	i += 1


I = lambda : list(map(int, input().split()))
for tc in range(int(input())):
	(n, k) = I()
	temp = k // (n - 1)
	k -= temp * (n - 1)
	if k:
		k += 1
	print(temp * n + k - 1)


import math
for i in range(int(input())):
	(n, k) = list(map(int, input().split()))
	if n > k:
		print(k)
		continue
	c = n - 1
	z = math.ceil(k / c - 1)
	q = c * z
	print(n * z + (k - q))


def rec(s, n, k):
	if k < n:
		print(k + s)
	else:
		x = k - k % n
		s = s + x
		k = k - (x - k // n)
		rec(s, n, k)
for _ in range(int(input())):
	(n, k) = list(map(int, input().split()))
	rec(0, n, k)


for _ in range(int(input())):
	(n, k) = map(int, input().split())
	d = n - 1
	if k % d == 0:
		a = k // d * n - 1
		print(a)
	else:
		a = k // d * n + k % d
		print(a)


t = int(input())
for i in range(t):
	(n, k) = map(int, input().split())
	r = int(k / (n - 1))
	r1 = k % (n - 1)
	s = n * r
	if r1 == 0:
		print(s - 1)
	else:
		print(s + r1)


t = int(input())
for T in range(t):
	(n, k) = [int(x) for x in input().split()]
	ans = k + (k - 1) // (n - 1)
	print(ans)


import sys
t = int(input())
for z in range(t):
	(n, k) = map(int, input().rstrip().split())
	m = k // (n - 1) * n + k % (n - 1)
	if n > k:
		print(k)
	elif k % (n - 1) == 0:
		print(m - 1)
	else:
		print(m)


x = int(input(''))
for i in range(x):
	arr = input('').split(' ')
	n = int(arr[0])
	k = int(arr[1])
	ans = (n * k - 1) // (n - 1)
	print(ans)


for _ in range(int(input())):
	(n, k) = map(int, input().split())
	t = n
	ans = k
	while t < k:
		ans += k // t
		t *= n
	while ans - ans // n != k:
		ans += 1
	print(ans)


t = int(input())
for _ in range(t):
	(n, k) = map(int, input().split())
	(no, count) = (k, 0)
	(rem, div) = (0, 0)
	ans = k
	while k >= n:
		div = k // n
		rem = k % n
		ans += div
		k = div + rem
	print(ans)


def notd(n, k):
	a = k // (n - 1) * n
	if (a + k % (n - 1)) % n == 0:
		print(a + k % (n - 1) - 1)
	else:
		print(a + k % (n - 1))
for q in range(int(input())):
	(n, k) = list(map(int, input().split()))
	notd(n, k)


def q3(n, k, d=0):
	d_n = k // n
	k = k + (d_n - d)
	ans1 = k // n
	if d_n == ans1:
		return k
	else:
		return q3(n, k, d=d_n)
t = int(input())
for q in range(t):
	(n, k) = tuple(map(int, input().split()))
	if n == k:
		print(n + 1)
	else:
		print(q3(n, k))


tc = int(input())
for _ in range(tc):
	(n, k) = map(int, input().split())
	r = k // (n - 1)
	ab = k % (n - 1)
	if ab == 0:
		print(r * n - 1)
	else:
		print(r * n + ab)


import math
t = int(input())
for i in range(0, t):
	(n, k) = map(int, input().split())
	if n > k:
		print(k)
	elif k % (n - 1) == 0:
		x = k // (n - 1)
		print(x * n - 1)
	else:
		x = k // (n - 1)
		print(x + k)


from sys import stdin as si

def evaluate(a, b):
	diff = a - 1
	y = b // diff
	z = b % diff
	ans = a * y + z
	if z == 0:
		ans -= 1
	return ans
for i in range(int(si.readline().strip())):
	(a, b) = map(int, si.readline().strip().split())
	print(evaluate(a, b))


t = int(input())
for _ in range(t):
	(n, k) = map(int, input().split())
	atleast_ns = int(k / (n - 1))
	subtractor = 0
	if k % (n - 1) == 0:
		subtractor = 1
	print(n * atleast_ns + (k - (n - 1) * atleast_ns) - subtractor)


for test in range(int(input())):
	(n, k) = map(int, input().split())
	count = k // n
	while (k + count) // n != count:
		count = (count + k) // n
	print(k + count)


import math
tt = input()
t = int(tt)
while t > 0:
	(n, k) = map(int, input().split())
	i = 1
	cnt = 1
	if n > k:
		ans2 = k
	elif n == k:
		ans2 = k + 1
	elif k % n == 0:
		ans2 = math.ceil(n / (n - 1) * k) - 1
		if ans2 % n == 0:
			ans2 += 2
	elif k % n != 0:
		ans1 = n / (n - 1) * k
		ans2 = math.ceil(ans1) - 1
	ans = round(ans2)
	print(ans)
	t -= 1


TC = int(input())

def solution(N, K):
	x = (K - 1) % (N - 1)
	y = (K - 1) // (N - 1)
	print(y * N + x + 1)
for _ in range(TC):
	(N, K) = map(int, input().split())
	solution(N, K)


for _ in ' ' * int(input()):
	(n, k) = map(int, input().split())
	print(k + k // (n - 1) - 1 + ((k + k // (n - 1)) % n != 0))


from sys import stdin
from math import gcd
inp = lambda : stdin.readline().strip()
t = int(inp())
for _ in range(t):
	(n, k) = [int(x) for x in inp().split()]
	if k % (n - 1) == 0:
		print(n * k // (n - 1) - 1)
	else:
		print(n * k // (n - 1))


import math
m = []
n = int(input())
for i in range(0, n):
	m.append([int(j) for j in input().split()])
for i in range(n):
	print(m[i][1] + math.floor((m[i][1] - 1) / (m[i][0] - 1)))


import math
t = int(input())
for i in range(t):
	(n, k) = input().split(' ')
	n = int(n)
	k = int(k)
	toMultiply = math.ceil(k / (n - 1))
	product = n * toMultiply
	covered = toMultiply * (n - 1)
	ans = product - 1 - (covered - k)
	print(ans)


import sys
strInp = lambda : input().strip().split()
intInp = lambda : list(map(int, strInp()))
for t in range(int(input())):
	(n, k) = intInp()
	x = k // (n - 1)
	if k % (n - 1) == 0:
		print(k + x - 1)
	else:
		print(k + x)


import sys, re, math
from collections import deque, defaultdict, Counter, OrderedDict
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians, gcd
from heapq import heappush, heappop, heapify, nlargest, nsmallest

def STR():
	return list(input())

def INT():
	return int(input())

def MAP():
	return map(int, input().split())

def LIST():
	return list(map(int, input().split()))

def list2d(a, b, c):
	return [[c] * b for i in range(a)]

def sortListWithIndex(listOfTuples, idx):
	return sorted(listOfTuples, key=lambda x: x[idx])

def sortDictWithVal(passedDic):
	temp = sorted(passedDic.items(), key=lambda kv: (kv[1], kv[0]))
	toret = {}
	for tup in temp:
		toret[tup[0]] = tup[1]
	return toret

def sortDictWithKey(passedDic):
	return dict(OrderedDict(sorted(passedDic.items())))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7
t = INT()
while t != 0:
	(n, k) = MAP()
	m = k // (n - 1)
	rem = k % (n - 1)
	if rem == 0:
		print(m * n - 1)
	else:
		print(n * m + rem)
	t -= 1


import math
t = int(input())
for i in range(0, t):
	nk = input().split()
	n = int(nk[0])
	k = int(nk[1])
	x = n * (k - 1) / (n - 1)
	y = n * k / (n - 1)
	if k == n:
		print(n + 1)
	else:
		for i in range(math.floor(x) + 1, math.ceil(y)):
			print(i)


for _ in range(int(input())):
	(n, k) = map(int, input().split())
	if k < n:
		print(k)
	elif n == k:
		print(n + 1)
	elif n == 2:
		print(2 * k - 1)
	else:
		from math import ceil
		c = ceil(k / (n - 1))
		i = k % (n - 1)
		if i == 0:
			print(n - 1 + n * (c - 1))
		else:
			print(n * (c - 1) + k % (n - 1))


for _ in range(int(input())):
	(n, k) = [int(x) for x in input().split()]
	(f, r) = (k // (n - 1), k % (n - 1))
	if r == 0:
		print(f * n - 1)
	else:
		print(f * n + r)


cases = int(input())
for i in range(cases):
	cadena = input().split()
	n = int(cadena[0])
	k = int(cadena[1])
	if k == n:
		print(k + 1)
	elif k == 1:
		print(1)
	elif n == 2 and k % n == 0:
		r = k * 2 - 1
		print(r)
	elif k < n:
		print(k)
	else:
		cociente = int(k / n)
		cociente1 = 0
		while cociente1 < k:
			suma = k + cociente
			cociente = int(suma / n)
			cociente1 = int(suma - cociente)
		print(suma)


import sys
input = sys.stdin.readline
(t,) = map(int, input().split())
for _ in range(t):
	(n, k) = map(int, input().split())
	r = k
	bc = 0
	while True:
		c = r // n
		if r - c < k:
			r += c - bc
			bc = c
			continue
		break
	print(r)


t = int(input())
for test in range(0, t):
	(n, k) = input().split()
	(n, k) = (int(n), int(k))
	prev = k
	idx = k + k // n
	while prev // n != idx // n:
		aux = idx
		idx += idx // n - prev // n
		prev = aux
	print(idx)


t = int(input())
ans = []
for i in range(t):
	(n, k) = map(int, input().split())
	q = (k * n + n - 2) // (n - 1) - 1
	ans += [q]
for i in ans:
	print(i)


t = int(input())
for _ in range(t):
	(n, k) = map(int, input().rstrip().split())
	diff = (k - 1) // (n - 1)
	print(diff + k)


for _ in range(int(input())):
	(n, k) = map(int, input().split())
	alt = 0
	neu = k // n
	while neu != alt:
		alt = neu
		neu = (k + neu) // n
	print(k + neu)


def main():
	(n, k) = map(int, input().split())
	if k < n:
		print(k)
		return
	temp = k // (n - 1)
	ans = n * temp + k - (n - 1) * temp
	if k % (n - 1) == 0:
		ans -= 1
	print(ans)
t = int(input())
while t:
	main()
	t -= 1


import sys
t = int(sys.stdin.readline())
for _ in range(t):
	(n, k) = map(int, sys.stdin.readline().split())
	prev = 0
	now = 0
	while True:
		now = k // n - prev
		k += now
		prev += now
		now = k // n
		if prev == now:
			print(k)
			break


import math
t = int(input())
while t > 0:
	t = t - 1
	(n, k) = map(int, input().split())
	k = k - 1
	block = k // (n - 1)
	m = n * block
	print(m + k % (n - 1) + 1)


from sys import stdout, stdin
for _ in range(int(stdin.readline())):
	(n, k) = map(int, stdin.readline().split())
	stdout.write('{:d}\n'.format(k + (k - 1) // (n - 1)))


t = int(input())
for i in range(t):
	(n, k) = map(int, input().split())
	skipped = k // n
	prev_skipped = 0
	while skipped > prev_skipped:
		d = skipped - prev_skipped
		k += d
		prev_skipped = skipped
		skipped = k // n
	print(k)


import math
for _ in range(int(input())):
	(N, K) = map(int, input().split())
	print(K + math.floor((K - 1) / (N - 1)))


def main():
	(n, k) = map(int, input().split())
	val = n - 1
	x = val
	cnt = 1
	if k % val == 0:
		cnt = k // val
	else:
		cnt = k // val + 1
	x *= cnt
	newval = n * cnt
	if x == k:
		print(newval - 1)
	else:
		xval = newval - val
		xval += k % val - 1
		print(xval)
for _ in range(int(input())):
	main()


t = int(input())
for test in range(t):
	temp = input()
	temp = temp.split(' ')
	n = int(temp[0])
	k = int(temp[1])
	res1 = k // (n - 1)
	res2 = k % (n - 1)
	if res2 == 0:
		print(res1 * n - 1)
	else:
		print(res1 * n + res2)


def main():
	n_t = int(input())
	for t in range(n_t):
		(n, k) = map(int, input().split(' '))
		block = k // (n - 1)
		if k % (n - 1) != 0:
			ans = n * block + k % (n - 1)
		else:
			ans = n * block - 1
		print(ans)
main()


import math
t = int(input())
for i in range(t):
	(n, k) = map(int, input().split())
	temp = k // (n - 1)
	rem = k % (n - 1)
	if rem == 0:
		rem = -1
	ans = temp * n + rem
	print(ans)


import sys
t = int(input())
while t:
	(n, k) = map(int, sys.stdin.readline().split())
	num = k // (n - 1)
	if k % (n - 1) == 0:
		print(k + num - 1)
	else:
		print(k + num)
	t -= 1


t = int(input())
for _ in range(t):
	(n, k) = map(int, input().split())
	c = int(k / n)
	tc = 0
	k = k + abs(c - tc)
	tc = int(k / n)
	while c != tc:
		k = k + abs(c - tc)
		c = tc
		tc = int(k / n)
	print(k)


t = int(input())
for j in range(t):
	(n, k) = [int(x) for x in input().split()]
	a = k // n
	b = k - a * n
	cont = a + b
	temp = cont
	while temp // n > 0:
		resto = temp % n
		temp //= n
		cont += temp
		temp += resto
	resp = a * n + cont
	print(resp)


t = input()
t = int(t)
shetchikshetchikov = 0
while shetchikshetchikov < t:
	(n, k) = input().split()
	n = int(n)
	k = int(k)
	shetchik123 = k
	if n == k:
		c = n + 1
		print(c)
	elif n == 2:
		c = n * k - 1
		print(c)
	else:
		sps = k
		spnov = k
		a = 0
		desps = sps // n
		k1 = k
		while a != spnov:
			a = spnov
			spnov = sps + desps
			desps = spnov // n
		print(spnov)
	shetchikshetchikov = shetchikshetchikov + 1


import sys
agGK = int(input())
for _ in range(agGK):
	(n, k) = map(int, input().split())
	t = k // (n - 1)
	h = (n - 1) * t
	b = n * t
	ans = b + (k - h)
	if h == k:
		print(b - 1)
		continue
	print(ans)


import math

def sol(n, k):
	chunk = math.ceil(k / (n - 1))
	target = n * (chunk - 1)
	toAdd = k - (n - 1) * (chunk - 1)
	return target + toAdd
t = int(input())
for _ in range(t):
	(n, k) = map(int, input().split())
	print(sol(n, k))


import sys
input = sys.stdin.readline
import random
import copy
import math

def main():
	q = int(input())
	for _ in range(q):
		(n, k) = map(int, input().split())
		nb_cyc = (k - 1) // (n - 1)
		print(k + nb_cyc)
main()


r = int(input())
for j in range(r):
	datos = input()
	A = [int(d) for d in datos.split()]
	n = A[0]
	k = A[1]
	Formula = k + (k - 1) // (n - 1)
	print(Formula)


for i in range(int(input())):
	(n, m) = map(int, input().split())
	if m % (n - 1) == 0:
		s = n * (m // (n - 1))
		print(s - 1)
	else:
		k = n * (m // (n - 1)) + m % (n - 1)
		print(k)


def solve(n, k):
	return k + (k - 1) // (n - 1)
for _ in range(int(input())):
	(n, k) = map(int, input().split())
	print(solve(n, k))


for _ in range(int(input())):
	(n, k) = map(int, input().split(' '))
	prev = 0
	a = -1
	while prev - k // n != 0:
		a = k // n
		k = k + (a - prev)
		prev = a
	print(k)


c = int(input())
for _ in range(c):
	str = input().split()
	n = int(str[0])
	k = int(str[1])
	if k * n % (n - 1) == 0:
		print(k * n // (n - 1) - 1)
	else:
		print(k * n // (n - 1))


from __future__ import division, print_function
import os
import sys
from io import BytesIO, IOBase
if sys.version_info[0] < 3:
	from __builtin__ import xrange as range
	from future_builtins import ascii, filter, hex, map, oct, zip

def main():
	for tin in range(int(input())):
		(n, k) = map(int, input().split())
		if k < n:
			print(k)
		elif k == n:
			print(n + 1)
		else:
			x = k
			t = (x - n) // n + 1
			a = [x]
			while 1 == 1:
				x = k + t
				t = (x - n) // n + 1
				a.append(x)
				if len(a) > 1 and a[-1] == a[-2]:
					break
			print(k + t)
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')

def print(*args, **kwargs):
	(sep, file) = (kwargs.pop('sep', ' '), kwargs.pop('file', sys.stdout))
	at_start = True
	for x in args:
		if not at_start:
			file.write(sep)
		file.write(str(x))
		at_start = False
	file.write(kwargs.pop('end', '\n'))
	if kwargs.pop('flush', False):
		file.flush()
if sys.version_info[0] < 3:
	(sys.stdin, sys.stdout) = (FastIO(sys.stdin), FastIO(sys.stdout))
else:
	(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
input = lambda : sys.stdin.readline().rstrip('\r\n')
main()


t = int(input())
for i in range(t):
	(n, k) = map(int, input().split())
	if n > k:
		print(k)
		continue
	no_of_times = int((k - 1) / (n - 1))
	last_index = no_of_times * n
	elements_to_go = k - int((n - 1) * no_of_times)
	print(last_index + elements_to_go)


t = int(input())
for i in range(t):
	(n, k) = map(int, input().split())
	if n == k:
		print(n + 1)
	elif n > k:
		print(k)
	else:
		c = k // (n - 1)
		r = k % (n - 1)
		if r == 0:
			ans = n * c - 1
		else:
			ans = n * c + r
		print(ans)


num = int(input())
for _ in range(num):
	(n, k) = map(int, input().split())
	res = k
	while True:
		t = res // n
		res = k + t
		pre = t
		t = res // n
		if t == pre:
			break
	print(res)


for tt in range(int(input())):
	l = [int(i) for i in input().split()]
	x = l[1] // (l[0] - 1) * l[0]
	if l[1] % (l[0] - 1) == 0:
		print(x - 1)
	else:
		print(x + l[1] % (l[0] - 1))


t = int(input())
for i in range(t):
	(n, k) = input().split()
	(n, k) = (int(n), int(k))
	need = int((k - 1) / (n - 1))
	print(round(k + need))


import os
import sys
from io import BytesIO, IOBase
import math
from decimal import *
from collections import defaultdict
getcontext().prec = 25
MOD = pow(10, 9) + 7
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
input = lambda : sys.stdin.readline().rstrip('\r\n')
for _ in range(int(input())):
	(n, k) = map(int, input().split(' '))
	ans = k
	t = k
	while k > n:
		t += k // n
		k = k // n + k % n
	print(ans + t // n)


t = int(input())
for case in range(t):
	(n, k) = map(int, input().split())
	num = n
	if k < n:
		print(k)
		continue
	div = n - 1
	m = k // div
	rest = k % div
	print(k + m + (0 if rest != 0 else -1))


def find_not_divisible(n, k, start_at, end_at):
	half = (start_at + end_at) // 2
	not_divisibles = half - half // n
	if start_at > end_at:
		return start_at
	if k <= not_divisibles:
		return find_not_divisible(n, k, start_at, half - 1)
	return find_not_divisible(n, k, half + 1, end_at)
n_tests = int(input())
(MIN_VALUE, MAX_VALUE) = (1, 10000000000000)
for i in range(n_tests):
	(n, k) = map(int, input().split())
	print(find_not_divisible(n, k, MIN_VALUE, MAX_VALUE))


t = int(input())
for j in range(t):
	(n, k) = map(int, input().split())
	h = k + k // n
	while h // n - k // n != 0:
		kufa = k
		k = h
		h += h // n - kufa // n
	print(h)


import math
for nt in range(int(input())):
	(n, k) = map(int, input().split())
	if k == n:
		print(k + 1)
		continue
	if k < n:
		print(k)
		continue
	print(k + math.ceil(k / (n - 1)) - 1)


from sys import stdin
input = stdin.readline
for _ in range(int(input())):
	(n, k) = map(int, input().split())
	if k >= n:
		p = k // n + k % n
		k += k // n
		while p:
			e = 0
			k += p // n
			if p > n:
				e = p % n
			p //= n
			p += e
		print(k)
	else:
		print(k)


def search(n, k, start, end):
	middle = (start + end) // 2
	if start == end:
		return middle
	div_by_n = middle // n
	not_div_by_n = middle - div_by_n * n + div_by_n * (n - 1)
	if not_div_by_n > k:
		res = search(n, k, start, middle - 1)
	elif not_div_by_n < k:
		res = search(n, k, middle + 1, end)
	else:
		res = middle
	return res
T = int(input())
for t in range(T):
	(n, k) = list(map(int, input().split()))
	res = search(n, k, 0, 3 * k)
	if res % n == 0:
		res -= 1
	print(res)


import math
t = int(input())
for _ in range(t):
	x = input().split()
	n = int(x[0])
	k = int(x[1])
	y = k // (n - 1)
	z = n * y
	x = k - (n - 1) * y
	if x == 0:
		x = -1
	ans = z + x
	print(ans)


t = int(input())
for w in range(t):
	nk = list(map(int, input().strip().split()))
	n = nk[0]
	k = nk[1]
	q = k // (n - 1)
	r = k % (n - 1)
	print(n * q + r - (r == 0))


import sys
import math
import itertools
import functools
import collections
import operator
import fileinput
import copy
ORDA = 97

def ii():
	return int(input())

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

def li():
	return [int(i) for i in input().split()]

def lcm(a, b):
	return abs(a * b) // math.gcd(a, b)

def revn(n):
	return str(n)[::-1]

def dd():
	return collections.defaultdict(int)

def ddl():
	return collections.defaultdict(list)

def sieve(n):
	if n < 2:
		return list()
	prime = [True for _ in range(n + 1)]
	p = 3
	while p * p <= n:
		if prime[p]:
			for i in range(p * 2, n + 1, p):
				prime[i] = False
		p += 2
	r = [2]
	for p in range(3, n + 1, 2):
		if prime[p]:
			r.append(p)
	return r

def divs(n, start=1):
	r = []
	for i in range(start, int(math.sqrt(n) + 1)):
		if n % i == 0:
			if n / i == i:
				r.append(i)
			else:
				r.extend([i, n // i])
	return r

def divn(n, primes):
	divs_number = 1
	for i in primes:
		if n == 1:
			return divs_number
		t = 1
		while n % i == 0:
			t += 1
			n //= i
		divs_number *= t

def prime(n):
	if n == 2:
		return True
	if n % 2 == 0 or n <= 1:
		return False
	sqr = int(math.sqrt(n)) + 1
	for d in range(3, sqr, 2):
		if n % d == 0:
			return False
	return True

def convn(number, base):
	newnumber = 0
	while number > 0:
		newnumber += number % base
		number //= base
	return newnumber

def cdiv(n, k):
	return n // k + (n % k != 0)
for _ in range(ii()):
	(n, k) = mi()
	print((k - 1) // (n - 1) + k)


import sys
from math import gcd, ceil, sqrt, ceil
from math import gcd, ceil, floor, sqrt, copysign, factorial, fmod, fsum, degrees
from math import expm1, exp, log, log2, acos, asin, cos, tan, sin, pi, e, tau, inf, nan, atan2
INF = float('inf')
MOD = 998244353
mod = 10 ** 9 + 7
from collections import Counter, defaultdict as df
from functools import reduce

def counter(l):
	return dict(Counter(l))

def printm(l):
	for i in range(len(l[0])):
		print(*l[i])

def P(n):
	if n <= 1:
		return False
	if n <= 3:
		return True
	if n % 2 == 0 or n % 3 == 0:
		return False
	for i in range(5, ceil(sqrt(n)) + 1, 6):
		if n % i == 0 or n % (i + 2) == 0:
			return False
	return True

def lcm(a, b):
	return int(a * b / gcd(a, b))

def so(x):
	return {k: v for (k, v) in sorted(x.items(), key=lambda item: item[1])}

def rev(l):
	return list(reversed(l))

def ini():
	return int(sys.stdin.readline())

def inp():
	return map(int, sys.stdin.readline().strip().split())

def li():
	return list(map(int, sys.stdin.readline().strip().split()))

def input():
	return sys.stdin.readline().strip()

def inputm(n, m):
	return [li() for i in range(n)]

def solve():
	(a, b) = inp()
	c = b // (a - 1)
	x = a * c
	x += b % (a - 1)
	if b % (a - 1) == 0:
		x -= 1
	print(x)
for i in range(ini()):
	solve()


for _ in range(int(input())):
	(n, k) = map(int, input().split())
	lo = 0
	hi = 10 ** 20

	def check(mi):
		return mi - mi // n >= k
	while lo <= hi:
		mi = (lo + hi) // 2
		if check(mi):
			ans = mi
			hi = mi - 1
		else:
			lo = mi + 1
	print(ans)


for _ in range(int(input())):
	(n, k) = map(int, input().split())
	(bot, top) = (0, 10000000000)
	mid = (bot + top) // 2
	while top - bot > 0:
		tmp = mid - mid // n
		if tmp == k:
			if mid % n == 0:
				print(mid - 1)
			else:
				print(mid)
			break
		elif tmp < k:
			bot = mid
		else:
			top = mid
		mid = (bot + top) // 2


t = int(input())
for i in range(t):
	nk = list(map(int, input().split()))
	n = nk[0]
	k = nk[1]
	rest = 0
	rest += k // n + k % n
	k += k // n
	while rest >= n:
		k += rest // n
		rest = rest % n + rest // n
	print(k)


t = int(input())
for y in range(t):
	lst0 = list(map(int, input().split()))
	(n, k) = (lst0[0], lst0[1])
	ge = k // (n - 1)
	sheng = k % (n - 1)
	if sheng == 0:
		print(ge * n + sheng - 1)
	else:
		print(ge * n + sheng)


import sys, math
I = sys.stdin.readline
pr = sys.stdout.write

def main():
	for _ in range(int(I())):
		(n, k) = map(int, I().split())
		pr(f'{k + math.ceil(k / (n - 1)) - 1}\n')
main()


import sys
input = lambda : sys.stdin.readline().rstrip()

def pin(type=int):
	return map(type, input().split())

def tupin(t=int):
	return tuple(pin(t))

def resolve():
	(Q,) = pin()
	for q in range(Q):
		(n, k) = pin()
		(a, b) = (k // (n - 1), k % (n - 1))
		if b == 0:
			b = -1
		print(a * n + b)
	print()
resolve()


def main():
	t = int(input())
	while t:
		t -= 1
		(n, k) = map(int, input().split())
		cnt = k // n
		while cnt < (k + cnt) // n:
			cnt = (k + cnt) // n
		print(cnt + k)
main()


import sys
sys.setrecursionlimit(10 ** 6)
int1 = lambda x: int(x) - 1
p2D = lambda x: print(*x, sep='\n')

def II():
	return int(sys.stdin.readline())

def MI():
	return map(int, sys.stdin.readline().split())

def LI():
	return list(map(int, sys.stdin.readline().split()))

def LLI(rows_number):
	return [LI() for _ in range(rows_number)]

def SI():
	return sys.stdin.readline()[:-1]

def main():
	for _ in range(II()):
		(n, k) = MI()
		g = (k + n - 2) // (n - 1) - 1
		i = (k - 1) % (n - 1) + 1
		print(g * n + i)
main()


for i in range(int(input())):
	(a, k) = map(int, input().split())
	print(k + (k - 1) // (a - 1))


for _ in range(int(input())):
	(n, k) = map(int, input().split())
	ans = 0
	c = k
	while c:
		q1 = ans // n
		ans += c
		q2 = ans // n
		c = q2 - q1
	print(ans)


def main():
	t = int(input())
	for _ in range(t):
		(n, k) = map(int, input().split())
		x = k // (n - 1)
		if k % (n - 1) > 0:
			x += 1
		curr = x * (n - 1)
		diff = curr - k
		print(x * n - (diff + 1))
main()


t = int(input())
for _ in range(t):
	(n, k) = map(int, input().split())
	if n == k:
		print(k + 1)
	elif n > k:
		print(k)
	else:
		a = (k - 1) // (n - 1)
		print(a + k)


t = int(input())
for _ in range(t):
	(n, k) = map(int, input().split())
	l = []
	p = k // (n - 1)
	m = k % (n - 1)
	num = n * p
	if m == 0:
		num -= 1
	else:
		num += m
	print(num)


import math
for _ in range(int(input())):
	(n, k) = map(int, input().split())
	m = k - k // n
	p = k
	d = k // n
	while m != p:
		k = k + d
		m = k - k // n
		d = p - m
	print(k)


import collections

def solve(n, k):
	ans = 0
	added = 0
	while True:
		totalNums = (k + added) // n
		prev = ans
		ans += totalNums - added
		if ans == prev:
			return ans + k
		added += totalNums - added
	return -1
t = int(input().strip())
for i in range(t):
	[n, k] = list(map(int, input().strip().split()))
	print(solve(n, k))


import sys

def binsearch_divisibility(n: int, k: int) -> int:
	(l, r) = (1, sys.maxsize)
	key = 0
	while l <= r:
		m = l + (r - l) // 2
		not_divisible_tillmid = m - m // n
		if not_divisible_tillmid > k:
			r = m - 1
		elif not_divisible_tillmid == k:
			key = m
			r = m - 1
		else:
			l = m + 1
	return key
t = int(input())
for _ in range(t):
	(n, k) = map(int, input().split())
	print(binsearch_divisibility(n, k))


import math

def func(a, b):
	rem = b % (a - 1)
	if not rem:
		rem = -1
	return a * math.floor(b / (a - 1)) + rem
n = int(input())
for i in range(n):
	(a, b) = map(int, input().split())
	print(func(a, b))


t = int(input())
for _ in range(t):
	(n, k) = map(int, input().split())
	m = (k - 1) // (n - 1)
	print(n * m + 1 + (k - 1) % (n - 1))


from math import floor

def kth(n, k):
	return k - floor(k / n)

def solve(n, k):
	start = 0
	end = pow(10, 10)
	while start <= end:
		mid = start + (end - start) // 2
		if mid % n == 0:
			mid += 1
		check = kth(n, mid)
		if check == k:
			return mid
		elif check < k:
			start = mid + 1
		else:
			end = mid - 1
	result = [k]
	while floor(result[-1] / n) > 0:
		result.append(floor(result[-1] / n))
	result = sum(result)
	if result % n == 0:
		result += 1
	return result
for i in range(int(input())):
	(n, k) = map(int, input().split())
	print(solve(n, k))


inp = lambda : map(int, input().split())
t = int(input())
for j in range(t):
	(n, k) = inp()
	x = n * (k // (n - 1))
	if k % (n - 1) == 0:
		x -= 1
	else:
		x += k % (n - 1)
	print(x)


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


t = int(input())
for i in range(t):
	ch = input()
	L = [int(i) for i in ch.split()]
	(n, k) = (L[0], L[1])
	x = k // (n - 1) + k
	if k % (n - 1) == 0:
		x -= 1
	print(x)


for _ in range(int(input())):
	(n, k) = list(map(int, input().split()))
	if k % (n - 1) != 0:
		x = k % (n - 1)
		a = x + n * (k // (n - 1))
	else:
		a = k // (n - 1) * n - 1
	print(a)


t = int(input())
for i in range(t):
	(n, k) = [int(i) for i in input().split()]
	ch = k + 1
	ch = k - 1
	c = ch // n
	while ch - c != k:
		ch += k - ch + c
		c = ch // n
	print(ch)


t = int(input())
for times in range(t):
	(n, k) = map(int, input().split())
	if k % (n - 1) == 0:
		x = k // (n - 1) * n - n
	else:
		x = k // (n - 1) * n
	plus = k % (n - 1)
	if plus == 0:
		plus = n - 1
	print(x + plus)


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


def process(n, k):
	multiplier = k // (n - 1)
	remainder = k % (n - 1)
	if remainder == 0:
		print(n * multiplier - 1)
	else:
		print(n * multiplier + remainder)
t = int(input())
for i in range(t):
	(n, k) = input().split()
	n = int(n)
	k = int(k)
	process(n, k)


import sys
for _ in range(int(sys.stdin.readline())):
	(n, k) = map(int, sys.stdin.readline().split())
	avan = (k - 1) // (n - 1)
	cand = n * avan
	k -= avan * (n - 1)
	cand += k
	print(cand)


def main():
	num_of_tests = int(input())
	for i in range(num_of_tests):
		(divisor, k_number) = map(int, input().split())
		solution = solver(divisor, k_number)
		sw_sol(solution)

def solver(divisor: int, k_num: int) -> int:
	answer = k_num + (k_num - 1) // (divisor - 1)
	return answer

def sw_sol(answer: int):
	print(answer)
main()


for _ in range(int(input())):
	(n, k) = map(int, input().split())
	h = k
	sum = 0
	while 1:
		c = k // n
		cc = k % n
		sum = sum + c
		k = c + cc
		if k < n:
			break
	print(h + sum)


for _ in range(int(input())):
	(n, k) = map(int, input().split())
	p = k // (n - 1)
	r = k % (n - 1)
	if r == 0:
		p = p - 1
	print(k + p)


for _ in range(int(input())):
	(n, k) = list(map(int, input().split()))
	x = n - 1
	f = k // x
	k = k % x
	minus = 0
	if k == 0:
		minus = 1
	mul = n * f
	print(mul + k - minus)


t = int(input())
for i in range(t):
	(n, k) = map(int, input().split())
	ans = n * k // (n - 1)
	if ans % n == 0:
		ans -= 1
	print(ans)


def bsearch(l, r, x, n):
	while l <= r:
		mid = (l + r) // 2
		if mid - mid // n == x and mid % n != 0:
			return mid
		elif mid - mid // n < x:
			l = mid + 1
		else:
			r = mid - 1
t = int(input())
for i in range(t):
	(n, k) = [int(x) for x in input().split()]
	print(bsearch(1, 2 * k, k, n))


t = int(input())
for i in range(t):
	(n, k) = map(int, input().split())
	row = (k - 1) // (n - 1)
	col = k - (n - 1) * row
	result = n * row + col
	print(result)


from collections import defaultdict as dd
from collections import Counter as ccd
from itertools import permutations as pp
from itertools import combinations as cc
from random import randint as rd
from bisect import bisect_left as bl
from bisect import bisect_right as br
import heapq as hq
import math
mod = pow(10, 9) + 7

def inp(flag=0):
	if flag == 0:
		return list(map(int, input().strip().split(' ')))
	else:
		return int(input())
for _ in range(int(input())):
	(n, k) = inp()
	print(k + (k - 1) // (n - 1))


def funcao(l, r):
	meio = int((l + r) / 2)
	posicao = meio - int(meio / n)
	if meio % n != 0 and posicao == k:
		return meio
	elif posicao >= k:
		return funcao(l, meio - 1)
	else:
		return funcao(meio + 1, r)
t = int(input())
res = []
i = 0
while i < t:
	entrada = input().split()
	n = int(entrada[0])
	k = int(entrada[1])
	li = 1
	ki = 2 * k
	res.append(funcao(li, ki))
	i += 1
for e in res:
	print(e)


import sys
input = sys.stdin.readline
for _ in range(int(input())):
	(n, k) = map(int, input().split())
	d = k * (n / (n - 1))
	if d == int(d):
		print(int(d - 1))
	else:
		print(int(d))


t = int(input())
while t > 0:
	(n, k) = map(int, input().split())
	x = -1
	val = k + k // n
	ans = k
	while x != 0:
		x = val // n - ans // n
		ans = val
		val = ans + x
	print(ans)
	t -= 1


import sys
import math

def solve():
	return None

def main():
	q = []
	for line in sys.stdin.readlines():
		q.append(line)
	for i in range(len(q)):
		q[i] = q[i].rstrip().split(' ')
		q[i] = [int(x) for x in q[i]]
	for i in range(1, len(q)):
		n = q[i][0]
		k = q[i][1]
		ret = 0
		if n == 2:
			ret = k * 2 - 1
		elif (k / (n - 1)).is_integer():
			ret = k + math.floor(k / (n - 1)) - 1
		else:
			ret = k + math.floor(k / (n - 1))
		if ret % n == 0:
			ret += 1
		print(ret)
main()


import sys
input = sys.stdin.readline
from math import log2, log, ceil

def swaparr(arr, a, b):
	temp = arr[a]
	arr[a] = arr[b]
	arr[b] = temp

def gcd(a, b):
	if a == 0:
		return b
	return gcd(b % a, a)

def nCr(n, k):
	if k > n - k:
		k = n - k
	res = 1
	for i in range(k):
		res = res * (n - i)
		res = res / (i + 1)
	return res

def upper_bound(a, x, lo=0):
	hi = len(a)
	while lo < hi:
		mid = (lo + hi) // 2
		if a[mid] < x:
			lo = mid + 1
		else:
			hi = mid
	return lo

def primefs(n):
	primes = {}
	while n % 2 == 0:
		primes[2] = primes.get(2, 0) + 1
		n = n // 2
	for i in range(3, int(n ** 0.5) + 2, 2):
		while n % i == 0:
			primes[i] = primes.get(i, 0) + 1
			n = n // i
	if n > 2:
		primes[n] = primes.get(n, 0) + 1
	return primes

def power(x, y, p):
	res = 1
	x = x % p
	if x == 0:
		return 0
	while y > 0:
		if y & 1 == 1:
			res = res * x % p
		y = y >> 1
		x = x * x % p
	return res

def swap(a, b):
	temp = a
	a = b
	b = temp
	return (a, b)

def find(x, link):
	p = x
	while p != link[p]:
		p = link[p]
	while x != p:
		nex = link[x]
		link[x] = p
		x = nex
	return p

def union(x, y, link, size):
	x = find(x, link)
	y = find(y, link)
	if size[x] < size[y]:
		(x, y) = swap(x, y)
	if x != y:
		size[x] += size[y]
		link[y] = x

def sieve(n):
	prime = [True for i in range(n + 1)]
	p = 2
	while p * p <= n:
		if prime[p] == True:
			for i in range(p * p, n + 1, p):
				prime[i] = False
		p += 1
	return prime
MAXN = int(1000000.0 + 5)

def spf_sieve():
	spf[1] = 1
	for i in range(2, MAXN):
		spf[i] = i
	for i in range(4, MAXN, 2):
		spf[i] = 2
	for i in range(3, ceil(MAXN ** 0.5), 2):
		if spf[i] == i:
			for j in range(i * i, MAXN, i):
				if spf[j] == j:
					spf[j] = i

def factoriazation(x):
	ret = {}
	while x != 1:
		ret[spf[x]] = ret.get(spf[x], 0) + 1
		x = x // spf[x]
	return ret

def int_array():
	return list(map(int, input().strip().split()))

def str_array():
	return input().strip().split()
MOD = int(1000000000.0) + 7
CMOD = 998244353
INF = float('inf')
NINF = -float('inf')
for _ in range(int(input())):
	(n, k) = int_array()
	x = k // (n - 1) * n
	t = k % (n - 1)
	if t == 0:
		x -= 1
	else:
		x += t
	print(x)


def solution(n, k):
	x = k // (n - 1)
	l = k + x
	if l % n == 0:
		print(l - 1)
	else:
		print(l)

def main():
	n = int(input())
	numbers = []
	for _ in range(n):
		(m, n) = input().split()
		numbers.append([int(m), int(n)])
	for i in numbers:
		solution(i[0], i[1])
main()


def ans(start, n, k):
	if k < n:
		return start + k
	else:
		a = k // n * (n - 1)
		return ans(start + k - k % n, n, k - a)
t = int(input())
for _ in range(t):
	(n, k) = map(int, input().split())
	print(ans(0, n, k))


def check(n, k):
	div = k // (n - 1)
	rem = k % (n - 1)
	number = div * n + rem
	if rem == 0:
		number -= 1
	return number
t = int(input())
i = 0
while i < t:
	arr = list(map(int, input().split()))
	n = check(arr[0], arr[1])
	print(n)
	i += 1


from sys import stdin
input = stdin.buffer.readline
for _ in range(int(input())):
	(n, k) = map(int, input().split())
	print(k // (n - 1) * n + k % (n - 1) - (1 if k % (n - 1) == 0 else 0))


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


for _ in range(int(input())):
	(N, K) = map(int, input().split())
	x = K // (N - 1)
	if K % (N - 1):
		print(x * N + K % (N - 1))
	else:
		print((x - 1) * N + N - 1)


t = int(input())
for _ in range(t):
	(n, k) = map(int, input().split())
	(l, r) = (0, int(1e+20))
	while l < r - 1:
		mid = (l + r) // 2
		if mid - mid // n < k:
			l = mid
		else:
			r = mid
	print(l + 1)


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


def foo(d, e):
	if d <= e:
		return d // e
	return d // e + foo(d // e + d % e, e)
t = int(input())
for i in range(t):
	(n, k) = map(int, input().split())
	k += foo(k, n)
	print(k)


def rank(n, x):
	return x - x // n
t = int(input())
for tt in range(t):
	nk = input().split()
	n = int(nk[0])
	k = int(nk[1])
	q = n - 1
	flag = False
	if (k - q) % (n - 1) == 0:
		p = (k - q) // (n - 1)
		m = p * n + q
		if rank(n, m) == k:
			print(m)
			flag = True
	if flag == False:
		p = k // (n - 1)
		q = k % (n - 1)
		m = p * n + q
		print(m)


from fractions import Fraction
import bisect
import os
from collections import Counter
import bisect
from collections import defaultdict
import math
import random
import heapq as hq
from math import sqrt
import sys
from functools import reduce, cmp_to_key
from collections import deque
import threading
from itertools import combinations
from io import BytesIO, IOBase
from itertools import accumulate

def input():
	return sys.stdin.readline().strip()

def iinput():
	return int(input())

def tinput():
	return input().split()

def rinput():
	return map(int, tinput())

def rlinput():
	return list(rinput())
mod = int(1000000000.0) + 7

def factors(n):
	return set(reduce(list.__add__, ([i, n // i] for i in range(1, int(n ** 0.5) + 1) if n % i == 0)))
t = 1
t = iinput()
for _ in range(t):
	(n, k) = rinput()
	ans = k
	while k // n > 0:
		ans += k // n
		k = k // n + k % n
	print(ans)


import math
tests = int(input())
for test in range(tests):
	(n, k) = map(int, input().split())
	p = n - 1
	c = math.floor(k / p)
	num = n * c
	if k % p == 0:
		print(num - 1)
	else:
		print(num + k % p)


interactions = int(input())
while interactions > 0:
	cnt = 0
	temp = 0
	entry = input().split(' ')
	n = int(entry[0])
	k = int(entry[1])
	while True:
		temp = int(k / n - cnt)
		if temp <= 0:
			break
		k += temp
		cnt += temp
	interactions -= 1
	print(k)


test_cases = int(input())
for _ in range(test_cases):
	(n, k) = map(int, input().split(' '))
	rows = (k - 1) // (n - 1)
	print(rows * n + k - rows * (n - 1))


for _ in range(int(input())):
	(n, k) = map(int, input().split())
	ans = 0
	if k == 1:
		print(1)
	else:
		ans = int(k / (1 - 1 / n))
		if ans // n + k == ans and ans % n != 0:
			print(ans)
		else:
			print(ans - 1)


import sys
import math
from collections import Counter, defaultdict
try:
	sys.stdin = open('input.txt', 'r')
	sys.stdout = open('output.txt', 'w')
except:
	pass

def takeInput():
	return [int(x) for x in input().strip().split()]
t = int(input())
while t != 0:
	t -= 1
	(n, k) = takeInput()
	if k > n:
		ans = float('inf')
		if n == 2:
			ans = 2 * k - 1
		rem = k // n
		count = k
		start = 1
		end = 2 * k + 1
		while start <= end:
			mid = start + (end - start) // 2
			rem = mid - mid // n
			if rem == k:
				ans = min(ans, mid)
			if rem < k:
				start = mid + 1
			else:
				end = mid - 1
		print(ans)
	elif k == n:
		print(k + 1)
	else:
		print(k)


t = int(input())
for _ in range(t):
	(n, k) = map(int, input().split())
	(a, b) = (k, 0)
	out = a
	while True:
		(a, b) = divmod(a + b, n)
		out += a
		if a == 0:
			break
	print(out)


for i in range(int(input())):
	(n, k) = map(int, input().split())
	m = k // n
	while (k + m) // n != m:
		m = (k + m) // n
	print(k + m)


def _print(array):
	for e in array:
		print(e)

def not_div(n, k):
	if k < n:
		return k
	q = 1
	n_div = 0
	while q != k:
		n_div = int(k / n) - int(q / n)
		q = k
		k += n_div
	return k
t = int(input())
res = []
for i in range(t):
	(n, k) = [int(a) for a in input().split(' ')]
	res += [not_div(n, k)]
_print(res)


from sys import stdin
input = iter(stdin.readlines()).__next__
t = int(input())
for _ in range(t):
	(n, k) = map(int, input().split())
	res = k
	div = 0
	last_div = 0
	while True:
		div = res // n - last_div
		last_div += div
		if div == 0:
			break
		res += div
	print(res)


def main():
	(n, k) = map(int, input().split())
	num = k / (n - 1)
	if num == int(num):
		print(n * int(num) - 1)
	else:
		print(n * int(num) + k % (n - 1))
t = int(input())
for _ in range(t):
	main()


for _ in range(int(input())):
	(n, k) = map(int, input().split())
	d = k // n
	a = k + d
	while a // n != d:
		c = a // n
		a += c - d
		d = c
	print(a)


import math

def ans(a, b):
	b -= 1
	print(b // (a - 1) * a + b % (a - 1) + 1)
t = int(input())
while t > 0:
	k = []
	(a, b) = map(int, input().split())
	ans(a, b)
	t -= 1


t = int(input())
for _ in range(t):
	(n, k) = input().split()
	n = int(n)
	k = int(k)
	c = k // (n - 1)
	i = n * c + (k - (n - 1) * c)
	if k % (n - 1) == 0:
		print(i - 1)
	else:
		print(i)


t = int(input())
while t:
	(n, k) = list(map(int, input().split()))
	extra = k % (n - 1)
	key = k // (n - 1)
	if k % (n - 1) == 0:
		key -= 1
		extra = n - 1
	result = n * key + extra
	print(result)
	t -= 1


from math import floor
t = int(input())
for i in range(t):
	(n, k) = map(int, input().split())
	x = k / (n - 1)
	if x == k // (n - 1):
		x = int(x) - 1
	else:
		x = int(x)
	y = x * n
	z = x * (n - 1)
	y += k - z
	print(y)


for _ in range(int(input())):
	(n, k) = map(int, input().split())
	t = k // (n - 1)
	temp = k - (n * t - t)
	ans = n * t + temp
	if ans % n == 0:
		ans -= 1
	print(ans)


T = int(input())
for t in range(T):
	(N, K) = [int(_) for _ in input().split()]
	under = K // N
	while under > 0:
		new_k = K + under
		under = new_k // N - K // N
		K = new_k
	print(K + under)


for test_case in range(int(input())):
	(n, k) = map(int, input().split())
	tutu = k
	if n > k:
		print(k)
	else:
		while k >= n:
			tutu += k // n
			k = k // n + k % n
		print(tutu)


times = int(input())
for i in range(times):
	number = input().split()
	n = int(number[0])
	k = int(number[1])
	count = 0
	prod = n * k
	answer = prod // (n - 1)
	if prod % (n - 1) == 0:
		print(answer - 1)
	else:
		print(answer)


from sys import stdout, stdin
import io
import os
input = io.BytesIO(os.read(0, os.fstat(0).st_size)).readline
for _ in range(int(input())):
	(n, k) = map(int, input().split())
	a = k // (n - 1)
	if k % (n - 1) != 0:
		print(a * n + k % (n - 1))
	else:
		print(a * n - 1)


n = int(input())
for i in range(n):
	x = list(map(int, input().split()))
	r = x[1] // (x[0] - 1)
	d = x[1] % (x[0] - 1)
	if d == 0:
		r -= 1
	pp = r * (x[0] - 1)
	pp = x[1] - pp
	sumi = r * x[0] + pp
	print(sumi)


import sys

def read_int():
	return int(sys.stdin.readline())

def read_ints():
	return list(map(int, sys.stdin.readline().split()))
t = read_int()
input1 = [(3, 7), (4, 12), (2, 1000000000), (7, 97), (1000000000, 1000000000), (2, 1)]
for j in range(t):
	(n, k) = read_ints()
	cur = 0
	lost = k
	inside = lost // n - cur // n
	while lost > 0:
		inside = (cur + lost) // n - cur // n
		cur = cur + lost
		lost = inside
	print(cur)


lst = []
i = int(input())
for i in range(0, i):
	lst.append(input().split())
for i in range(0, len(lst)):
	x = int(lst[i][0])
	y = int(lst[i][1])
	if y % (x - 1) == 0:
		print(x * (y // (x - 1)) - 1)
	else:
		print(x * (y // (x - 1)) + y % (x - 1))


import math
t = int(input())
for x in range(t):
	(n, k) = map(int, input().split())
	print(k + math.floor((k - 1) / (n - 1)))


import sys
t = int(input())

def bs(l, h, n, k):
	if l <= h:
		m = (l + h) // 2
		temp = m - m // n
		if temp == k:
			if m % n != 0:
				return m
			return bs(l, m - 1, n, k)
		if temp < k:
			return bs(m + 1, h, n, k)
		else:
			return bs(l, m - 1, n, k)
for i1 in range(t):
	(n, k) = map(int, input().split(' '))
	m = 10 ** 30
	z = bs(0, m, n, k)
	print(z)


for _ in range(int(input())):
	(n, k) = list(map(int, input().split()))
	r = k % (n - 1)
	d = k // (n - 1)
	if r == 0:
		r = -1
	print(n * d + r)


a = int(input())
for x in range(a):
	a = [int(x) for x in input().split()]
	answer = a[1] // (a[0] - 1) * a[0]
	if a[1] % (a[0] - 1) == 0:
		answer -= 1
	else:
		answer += a[1] % (a[0] - 1)
	print(answer)


test = int(input())
for _ in range(test):
	(n, k) = map(int, input().split())
	groups = k // (n - 1)
	suma = k % (n - 1) if k % (n - 1) > 0 else -1
	print(groups * n + suma)


numTest = int(input())
for _ in range(numTest):
	inputLine = input()
	tempStr = inputLine.split(' ')
	thisDiv = int(tempStr[0])
	thisOrd = int(tempStr[1])
	if thisDiv == thisOrd:
		print(thisDiv + 1)
	elif thisDiv > thisOrd:
		print(thisOrd)
	else:
		thisSum = int(thisOrd / (thisDiv - 1))
		thisRemain = int(thisOrd % (thisDiv - 1))
		if thisRemain == 0:
			print(int(thisDiv * thisSum - 1))
		else:
			print(int(thisDiv * thisSum + thisRemain))


import sys
import math
T = int(sys.stdin.readline())
for _ in range(0, T):
	(N, K) = list(map(int, sys.stdin.readline().split(' ')))
	mid = N - 1
	term = int(math.ceil(K / mid)) - 1
	idx = 0
	result = 0
	idx += N * term
	result += mid * term
	aterm = K - result
	print(idx + aterm)


import math

def solve():
	(n, k) = list(map(int, input().split()))
	a = int(k * n / (n - 1))
	if a % n == 0:
		a -= 1
	print(a)

def main():
	t = int(input())
	for _ in range(t):
		solve()
main()


for _ in range(int(input())):
	(n, k) = map(int, input().split())
	ans = k
	f = n
	if k % n == 0:
		l = k
	else:
		l = k // n * n
	cnt = (l - f) // n + 1
	while cnt != 0:
		f = ans // n * n + n
		ans += cnt
		if ans % n == 0:
			l = ans
		else:
			l = ans // n * n
		cnt = (l - f) // n + 1
	print(ans)


t = int(input())
for i in range(0, t):
	(b, a) = map(int, input().split())
	resultados = int(b * a / (b - 1)) - 1
	while resultados - int(resultados / b) != a:
		resultados += 1
	print(resultados)


from collections import *
import sys

def ri():
	return int(input())

def rl():
	return list(map(int, input().split()))
t = ri()
for _ in range(t):
	(n, k) = rl()
	q = (k - 1) // (n - 1)
	print(k + q)


t = int(input())
for i in range(t):
	l = input().split()
	n = int(l[0])
	k = int(l[1])
	ini = 0
	fin = 1000000000
	while ini < fin:
		med = int((ini + fin) / 2)
		if med * (n - 1) <= k:
			ini = med + 1
		else:
			fin = med
	ini = ini - 1
	ans = n * ini
	ans = ans + (k - ini * (n - 1))
	if k == ini * (n - 1):
		ans = ans - 1
	print(ans)


for _ in range(int(input())):
	(n, k) = list(map(int, input().strip().split()))
	if n == k:
		print(k + 1)
	elif n > k:
		print(k)
	elif k % (n - 1) != 0:
		print(k + k // (n - 1))
	else:
		print(k + k // (n - 1) - 1)


from math import ceil
for _ in range(int(input())):
	(n, k) = map(int, input().split())
	ans = k / (n - 1) * n
	ans = ceil(ans)
	print(ans - 1)


MOD = 1000000007
ii = lambda : int(input())
si = lambda : input()
dgl = lambda : list(map(int, input()))
f = lambda : map(int, input().split())
il = lambda : list(map(int, input().split()))
ls = lambda : list(input())
for _ in range(ii()):
	(n, a) = f()
	if a % (n - 1) == 0:
		print(a // (n - 1) * n + a % (n - 1) - 1)
	else:
		print(a // (n - 1) * n + a % (n - 1))


T = int(input())
while T:
	T = T - 1
	(n, k) = input().split()
	N = int(n)
	K = int(k)
	v1 = int(K / (N - 1))
	v2 = K % (N - 1)
	if v2 != 0:
		print(v1 * N + v2)
	else:
		print(v1 * N - 1)


from math import floor
t = int(input())
for _ in range(t):
	(n, k) = [int(x) for x in input().split()]
	left = 0
	right = k
	d = -1
	ans = -1
	while d != 0:
		x = floor(left / n)
		y = floor(right / n)
		d = y - x
		left = right
		right += d
		ans = right
	print(ans)


import math

def main():
	t = int(input())
	for i in range(t):
		(n, k) = map(int, input().split())
		p = math.ceil(k / (n - 1)) - 1
		print(k + p)
main()


def calcKthNum(n, k):
	if k < n:
		return k
	elif n == k:
		return n + 1
	elif n == 2:
		return 2 * k - 1
	else:
		T = 0
		m = 0
		if k % (n - 1) != 0:
			m = int(k / (n - 1))
		else:
			m = int(k / (n - 1)) - 1
		T += m * n
		k -= m * (n - 1)
		T += k
		return T
t = int(input())
result = ''
for i in range(t):
	[n, k] = input().split(' ')
	n = int(n)
	k = int(k)
	r = calcKthNum(n, k)
	result += str(r) + '\n'
print(result)


t = int(input())

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


test = int(input())
for i in range(test):
	(n, k) = map(int, input().split())
	temp = k + (k - 1) // (n - 1)
	print(temp)


from math import floor
for _ in range(int(input())):
	(n, k) = map(int, input().split())
	if k >= n:
		pos = int(1000000000.0 + 1)
		val = k // n
		k += val
		while pos - val:
			pos = k // n
			diff = pos - val
			k += diff
			val = pos
			pos = k // n
		if k % n == 0:
			print(k + 1)
		else:
			print(k)
	else:
		print(k)


test = int(input())
for t in range(test):
	(n, k) = map(int, input().split())
	l = (k - 1) // (n - 1)
	print(k + l)


qtd = int(input())
for i in range(qtd):
	(k, n) = map(int, input().split())
	resultado = int(n + n / (k - 1))
	print(resultado - 1 if resultado % k == 0 else resultado)


for _ in range(0, int(input())):
	nk = list(map(int, input().split()))
	n = nk[0]
	k = nk[1]
	q = int(k / (n - 1))
	rem = k % (n - 1)
	if rem == 0:
		rem = -1
	print(n * q + rem)


t = int(input())
while t > 0:
	(n, k) = input().split(' ')
	n = int(n)
	k = int(k)
	n1 = n - 1
	n2 = k // n1
	if n2 * n1 - k == 0:
		print(n * n2 - 1)
	else:
		n2 = k // n1
		print(abs(n2 * n1 - k) + n2 * n)
	t = t - 1


for test in range(int(input())):
	(n, k) = map(int, input().split())
	su = k
	if n > k:
		print(k)
	else:
		while k >= n:
			su += k // n
			k = k // n + k % n
		print(su)


import sys
input = sys.stdin.buffer.readline
from collections import defaultdict
con = 10 ** 9 + 7
INF = float('inf')

def getlist():
	return list(map(int, input().split()))

def main():
	N = int(input())
	for _ in range(N):
		(n, k) = getlist()
		if k % (n - 1) == 0:
			ans = n * int(k // (n - 1)) - 1
		else:
			ans = n * int(k // (n - 1)) + k % (n - 1)
		print(ans)
main()


for _ in range(int(input())):
	(n, k) = map(int, input().split())
	start = 1
	save = []
	if k < n:
		print(k)
	else:
		(times, rest) = divmod(k, n - 1)
		if rest:
			print(n * times + rest)
		else:
			print(n * times - 1)


for t in range(int(input())):
	(n, k) = map(int, input().split(' '))
	k -= 1
	group = k // (n - 1)
	ing = k % (n - 1)
	print(group * n + 1 + ing)


from math import ceil
from queue import LifoQueue

def print_sol(c, sol):
	print('Case #{}: {}'.format(c, sol))

def rd_int():
	return int(input())

def rd_str():
	return input()

def rd_str_lst():
	return input().split(' ')

def sp_str_lst():
	return list(input())

def rd_int_lst():
	return [int(i) for i in rd_str_lst()]

def sp_int_lst():
	return [int(i) for i in sp_str_lst()]

def dfs(g, i, v):
	v[i] = True
	for j in g[i]:
		if not v[j]:
			dfs(g, j, v)
	print(i)

def dfs_iter(g, i, n):
	v = [False] * n
	stack = LifoQueue()
	stack.put(i)
	while stack.not_empty:
		u = stack.get()
		v[u] = True
		print(u)
		for i in g[u]:
			if not v[i]:
				stack.put(i)

def hapi(g, i, d, va, da, sa):
	va[i] = True
	d += 1
	da[i] = d
	sa[i] = 1
	for j in g[i]:
		if not va[j]:
			hapi(g, j, d, va, da, sa)
			sa[i] += sa[j]

def hapi_iter(g, i, n):
	va = [False] * n
	da = [0] * n
	sa = [0] * n
	stack = LifoQueue()
	stack.put(i)
	while stack.not_empty:
		u = stack.get()
		va[u] = True
		print(u)
		for i in g[u]:
			if not va[i]:
				stack.put(i)

def main():
	t = rd_int()
	for c in range(1, t + 1):
		(n, k) = rd_int_lst()
		s = ceil(k * (n / (n - 1)) - 1)
		print(s)
main()


t = int(input())
for i in range(t):
	(n, k) = map(int, input().split())
	l = 1
	h = n * (k + 1)
	while l <= h:
		mid = (l + h) // 2
		if mid % n == 0:
			mid += 1
		num = mid // n
		past = num * (n - 1) + mid % n
		if past < k:
			l = mid + 1
		elif past > k:
			h = mid - 1
		else:
			break
	print(mid)


t = int(input())
for _ in range(t):
	(n, k) = list(map(int, input().split()))
	key = k
	prevkey = 0
	flag = False
	while not flag:
		v = key // n
		key -= prevkey
		key += v
		if v == prevkey:
			flag = True
		prevkey = v
	print(key)


import math
t = int(input())
for i in range(t):
	l = [int(k) for k in input().split()]
	n = l[0]
	k = l[1]
	s = k / (n - 1)
	s = math.ceil(s)
	a = k + s - 1
	print(a)


maxnum = 10000000000

def val(maxi, n):
	q = maxi // n
	return maxi - q

def bins(lo, hi, n, k):
	while lo < hi:
		mid = (lo + hi) // 2
		if val(mid, n) >= k:
			hi = mid
		else:
			lo = mid + 1
	return lo
t = int(input())
for _ in range(t):
	(n, k) = map(int, input().split())
	ans = bins(1, maxnum, n, k)
	print(ans)


from math import ceil
for ix in range(int(input())):
	(n, k) = map(int, input().split())
	x = k % (n - 1)
	k -= x
	aa = n * (k // (n - 1)) + x
	if aa % n == 0:
		aa -= 1
	print(aa)


def main():
	t = int(input())
	l = []
	for i in range(t):
		(n, k) = map(int, input().split())
		maxi = 10 ** 9 * 2
		mini = 1
		while maxi != mini:
			srednji = (maxi + mini) // 2
			djeljivi = srednji // n
			if srednji - djeljivi == k and srednji % n != 0:
				l.append(srednji)
				break
			if srednji - djeljivi < k:
				mini = srednji + 1
			else:
				maxi = srednji - 1
		else:
			djeljivi = maxi // n
			if maxi - djeljivi == k:
				l.append(maxi)
	for i in l:
		print(i)
main()


t = int(input())
for _ in range(t):
	(n, k) = map(int, input().split())
	g = n - 1
	if k % g == 0:
		print(int(k / g * n - 1))
	else:
		h = int(k / g)
		ans = h * g
		s = k - ans
		print(int(n * h + s))


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


cases = int(input())
for i in range(cases):
	line1 = input().split(' ')
	d = int(line1[0])
	pos = int(line1[1])
	if pos < d:
		print(pos)
	else:
		calc = pos % (d - 1)
		calc2 = int(pos / (d - 1))
		if calc == 0:
			ans = calc2 * d - 1
		else:
			ans = calc2 * d + calc
		print(ans)


t = int(input())
for i in range(t):
	(n, k) = map(int, input().split())
	c = n - 1
	l = k // c
	u = l * n
	if k % c == 0:
		d = u - 1
	else:
		d = k - l * c
		d += u
	print(d)


t = int(input())
for _ in range(t):
	(n, k) = map(int, input().split())
	res = int(k / (n - 1))
	mod = int(k % (n - 1))
	if mod == 0:
		print(n * res - 1)
	else:
		print(n * res + mod)


L = [tuple(map(int, input().split())) for _ in range(int(input()))]
for i in range(len(L)):
	print(L[i][1] + (L[i][1] - 1) // (L[i][0] - 1))


c = int(input())
for z in range(c):
	i = input().split(' ')
	print((int(i[1]) - 1) // (int(i[0]) - 1) + int(i[1]))


t = int(input())
ww = []
for i in range(t):
	(n, k) = input().split()
	n = int(n)
	k = int(k)
	r = k // (n - 1)
	l = k % (n - 1)
	if l == 0:
		s = r * n - 1
		ww.append(s)
	else:
		s = r * n + l
		ww.append(s)
for z in ww:
	print(z)


t = int(input())
for _ in range(t):
	(n, k) = map(int, input().split())
	r = n - 1
	k -= 1
	steps = k // r
	res = steps * n + 1 + k % r
	print(res)


t = int(input())
for _ in range(t):
	(n, k) = map(int, input().split())
	if k < n:
		print(k)
	elif k == n:
		print(n + 1)
	else:
		v = k // (n - 1)
		vb = k % (n - 1)
		b = n * v
		if vb == 0:
			print(b - 1)
		else:
			print(b + vb)


for _ in range(int(input())):
	a = input().split(' ')
	n = int(a[0])
	k = int(a[1])
	val = k // n
	ans = k + val
	while ans // n != val:
		val1 = ans // n
		ans = ans + ans // n - val
		val = val1
	if ans % n == 0:
		ans = ans + 1
	print(ans)


for _ in range(int(input())):
	(n, k) = map(int, input().split())
	ans = k
	fast = n
	if k % n == 0:
		last = k
	else:
		last = k // n * n
	b = (last - fast) // n + 1
	while b != 0:
		fast = ans // n * n + n
		ans += b
		if ans % n == 0:
			last = ans
		else:
			last = ans // n * n
		b = (last - fast) // n + 1
	print(ans)


def funca(n, k):
	(l, r) = (1, 2 * k)
	while l < r:
		mid = (l + r) // 2
		if mid - mid // n <= k:
			l = mid
		else:
			r = mid - 1
	return l

def func(n, k):
	(l, r) = (1, 2 * k)
	while l < r:
		mid = (l + r) // 2
		if mid - mid // n >= k:
			r = mid
		else:
			l = mid + 1
	return r

def func1(n, k):
	(l, r) = (1, 2 * k)
	while l < r:
		mid = (l + r) // 2
		if mid - mid // n >= k:
			r = mid
		else:
			l = mid + 1
	return l
t = int(input())
for _ in range(t):
	(n, k) = map(int, input().split())
	print(func(n, k))


import math

def solve(n, k):
	r = math.ceil(k / (n - 1))
	if k % (n - 1) == 0:
		return int(r * n) - 1
	else:
		return int((r - 1) * n) + k % (n - 1)
t = int(input())
for i in range(t):
	(n, k) = tuple(map(int, input().split()))
	print(solve(n, k))


from math import floor
t = int(input())
for i in range(t):
	array = list(input().split(' '))
	n = int(array[0])
	k = int(array[1])
	s = floor(k / (n - 1))
	j = n * s
	l = k % (n - 1)
	if l == 0:
		print(j - 1)
	else:
		print(j + l)


for _ in range(int(input())):
	(a, b) = [*map(int, input().split())]
	if b % (a - 1) == 0:
		su = b % (a - 1) - 1
		ans = a * (b // (a - 1)) + su
	else:
		ans = a * (b // (a - 1)) + b % (a - 1)
	print(ans)


t = int(input())
while t != 0:
	t -= 1
	(n, k) = [int(x) for x in input().split()]
	nd = n - 1
	if k % nd == 0:
		print(k // nd * n - 1)
	else:
		print(k // nd * n + k % nd)


t = int(input())
for _ in range(t):
	(n, k) = list(map(int, input().split()))
	sum_ = k
	while k >= n:
		sum_ += k // n
		k = k // n + k % n
	print(sum_)


t = int(input())
for _ in range(t):
	(n, k) = list(map(int, input().split()))
	r = k // n
	grp = r // (n - 1)
	if r % (n - 1) == 0:
		grp -= 1
	k += n * grp
	r -= grp * (n - 1)
	if k // n < (k + r) // n:
		k += 1
	k += r
	print(k)


import math
for _ in range(int(input())):
	(n, k) = list(map(int, input().split()))
	l = k // (n - 1)
	r = k % (n - 1)
	if r == 0:
		r = -1
	print(l * n + r)


T = int(input())
while T > 0:
	(n, k) = map(int, input().split())
	times = k // (n - 1)
	res = 0
	if k % (n - 1) == 0:
		res = times * n - 1
	else:
		res = times * n + k % (n - 1)
	print(res)
	T -= 1


def f(n, m):
	if m == 1:
		return -1
	return n + (n - 1) // (m - 1)
s = input()
if ' ' in s:
	ans = f(*map(int, s.split()))
	print('inf' if ans == -1 else ans)
else:
	s = int(s)
	for i in range(s):
		(m_, n_) = map(int, input().split())
		print(f(n_, m_))


for _ in range(int(input())):
	(n, k) = list(map(int, input().split()))
	r = n - 1
	x = k // r
	y = k % r
	res = n * x + y
	if y == 0:
		res = n * x + y - 1
	print(res)


a = int(input())
r = []
for i in range(a):
	x = [int(i) for i in input().split()]
	r.append(x)
for i in range(a):
	n = r[i][0]
	k = r[i][1]
	x = (k - 1) // (n - 1)
	print(k + x)


import math
for i in range(int(input())):
	(n, k) = list(map(int, input().split()))
	e = math.ceil(k / (n - 1)) - 1
	print(k + e)


import sys
import math
try:
	sys.stdin = open('input.txt', 'r')
	sys.stdout = open('output.txt', 'w')
except:
	pass

def takeInput():
	return [int(x) for x in input().strip().split()]
t = int(input())
while t != 0:
	t -= 1
	(n, k) = takeInput()
	shifts = (k - 1) // (n - 1)
	print(k + shifts)


import math
t = int(input())
for t in range(t):
	(n, k) = input().split()
	(n, k) = (int(n), int(k))
	kth = math.floor((k - 1) / (n - 1))
	kth += k
	print(kth)


for _ in range(int(input())):
	(n, k) = map(int, input().split())
	rem = k % (n - 1)
	d = k // (n - 1)
	p = n * d
	if rem == 0:
		print(p - 1)
	else:
		print(p + rem)


from bisect import bisect_left as bl
from bisect import bisect_right as br
from heapq import heappush, heappop
import math
from collections import *
from functools import reduce, cmp_to_key, lru_cache
import io, os
input = io.BytesIO(os.read(0, os.fstat(0).st_size)).readline
M = mod = 10 ** 9 + 7

def factors(n):
	return sorted(set(reduce(list.__add__, ([i, n // i] for i in range(1, int(n ** 0.5) + 1) if n % i == 0))))

def inv_mod(n):
	return pow(n, mod - 2, mod)

def li():
	return [int(i) for i in input().rstrip().split()]

def st():
	return str(input().rstrip())[2:-1]

def val():
	return int(input().rstrip())

def li2():
	return [str(i)[2:-1] for i in input().rstrip().split()]

def li3():
	return [int(str(i)[2:-1]) for i in input().rstrip()]
for _ in range(val()):
	(n, k) = li()
	i = k // (n - 1)
	if k % (n - 1) == 0:
		i -= 1
		k = n - 1
	else:
		k = k % (n - 1)
	print(n * i + k)


t = int(input())
for _ in range(t):
	(n, k) = map(int, input().split())
	num = n * k // (n - 1)
	num1 = n * k % (n - 1)
	if num1 == 0:
		num = num - 1
	print(num)


def check(m, n, k):
	c = m // n
	k -= (n - 1) * c
	k -= m % n
	return k <= 0
t = int(input())
for _ in range(t):
	(n, k) = tuple([int(e) for e in input().split()])
	b = 1
	e = int(10000000000.0)
	while b < e:
		m = (b + e) // 2
		if check(m, n, k):
			e = m
		else:
			b = m + 1
	if check(e, n, k):
		print(e)
	else:
		print(e - 1)


from sys import stdin, exit
from math import ceil
input = stdin.readline

def i():
	return input()

def ii():
	return int(input())

def iis():
	return map(int, input().split())

def liis():
	return list(map(int, input().split()))

def print_array(a):
	print(' '.join(map(str, a)))
t = ii()
for _ in range(t):
	(n, k) = iis()
	if k < n:
		print(k)
	else:
		cada = ceil(k / (n - 1))
		resto = cada * n
		final = resto - ((n - 1) * cada - k) - 1
		print(final)


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

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

def li():
	return list(mi())
abc = 'abcdefghijklmnopqrstuvwxyz'
abd = {'a': 0, 'b': 1, 'c': 2, 'd': 3, 'e': 4, 'f': 5, 'g': 6, 'h': 7, 'i': 8, 'j': 9, 'k': 10, 'l': 11, 'm': 12, 'n': 13, 'o': 14, 'p': 15, 'q': 16, 'r': 17, 's': 18, 't': 19, 'u': 20, 'v': 21, 'w': 22, 'x': 23, 'y': 24, 'z': 25}
mod = 1000000007
inf = float('inf')
vow = ['a', 'e', 'i', 'o', 'u']
(dx, dy) = ([-1, 1, 0, 0], [0, 0, 1, -1])

def read():
	c = 0
	if c:
		input = sys.stdin.readline
	else:
		sys.stdin = open('input1.txt', 'r')
		sys.stdout = open('output1.txt', 'w')

def solve():
	for _ in range(ii()):
		(n, k) = mi()
		c = k // (n - 1)
		x1 = c * n
		x1 += k % (n - 1)
		if k % (n - 1) == 0:
			x1 -= 1
		print(x1)
solve()


import os
import sys
from math import *
from collections import *
from bisect import *
from io import BytesIO, IOBase

def vsInput():
	sys.stdin = open('input.txt', 'r')
	sys.stdout = open('output.txt', 'w')
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
input = lambda : sys.stdin.readline().rstrip('\r\n')

def value():
	return map(int, input().split())

def array():
	return [int(i) for i in input().split()]
for _ in range(int(input())):
	(n, k) = value()
	set_no = k // (n - 1)
	m = k % (n - 1)
	if m != 0:
		print(n * set_no + m)
	else:
		print(n * set_no - 1)


import sys
for _ in range(int(input())):
	(n, k) = map(int, input().split())
	l = 1
	h = sys.maxsize
	ans = 0
	while l <= h:
		mid = (l + h) // 2
		sol = mid - mid // n
		if sol > k:
			h = mid - 1
		elif sol < k:
			l = mid + 1
		else:
			ans = mid
			h = mid - 1
	print(ans)


def solution():
	(n, k) = map(lambda x: int(x), input().split())
	print(k + (k - 1) // (n - 1))
t = int(input())
for _ in range(t):
	solution()


for _ in range(int(input())):
	(n, k) = map(int, input().split())
	p = n - 1
	ext = k % p
	tim = k // p
	if ext == 0:
		print(int(n * tim + ext - 1))
	else:
		print(int(n * tim + ext))


def f2(n, k):
	need = (k - 1) // (n - 1)
	print(need + k)
n = int(input())
for i in range(n):
	l = list(map(int, input().split()))
	f2(l[0], l[1])


T = int(input())
for _ in range(T):
	(n, k) = map(int, input().split())
	m = k // (n - 1)
	rem = k % (n - 1)
	n = n * m
	if rem == 0:
		print(n - 1)
	else:
		print(n + rem)


def main():
	T = int(input())
	for _ in range(T):
		(N, K) = list(map(int, input().split()))
		if K % (N - 1) != 0:
			print(N * (K // (N - 1)) + K % (N - 1))
		else:
			print(N * K // (N - 1) - 1)
main()


tcs = int(input())
for tc in range(tcs):
	(n, k) = map(int, input().split())
	if k % (n - 1) == 0:
		print(n * (k // (n - 1)) - 1)
	else:
		print(n * (k // (n - 1)) + k % (n - 1))


from sys import stdin, stdout
input = stdin.readline
print = stdout.write
for _ in range(int(input())):
	(n, k) = map(int, input().split())
	k -= 1
	r = k % (n - 1)
	x = k // (n - 1)
	r += x * n + 1
	print(str(r) + '\n')


N = int(input())
ans = []
for i in range(N):
	nk = input().split()
	n = int(nk[0])
	k = int(nk[1])
	if n == 2:
		ans.append(n * k - 1)
		continue
	T = k % n
	t = k // n
	k += t
	vax = T + t
	while True:
		if vax > n:
			k += vax // n
			vax = vax // n + vax % n
		else:
			break
	if k % n == 0:
		k += 1
	ans.append(int(k))
for i in ans:
	print(i)


n = int(input())
for i in range(n):
	t = input().split()
	n = int(t[0])
	k = int(t[1])
	temp = (k - 1) // (n - 1)
	tt = temp * n
	print(tt + k - temp * (n - 1))


import math
for pi in range(int(input())):
	(n, k) = map(int, input().split())
	a = 2
	noof = n - 1
	if k <= n - 1:
		print(1 + (k - 1) * 1)
		continue
	x = math.ceil(k / noof) - 1
	noof = noof * x + x
	print(noof + k - x * (n - 1))


import sys
input = sys.stdin.readline

def inlt():
	return list(map(int, input().split()))
t = int(input())
for i in range(t):
	l = inlt()
	n = l[0]
	k = l[1]
	ans = n * k
	if ans % (n - 1) == 0:
		print(int(ans / (n - 1)) - 1)
	else:
		print(int(ans / (n - 1)))


for f in range(int(input())):
	(n, k) = map(int, input().split())
	x = n * k // (n - 1)
	if k % (n - 1) == 0:
		x -= 1
	print(x)


from sys import stdin
t = int(input())
for _ in range(t):
	(n1, n2) = map(int, stdin.readline().rstrip().split(' '))
	total = n2
	while n2 > n1:
		to_add = n2 // n1
		total = total + to_add
		n2 = n2 // n1 + n2 % n1
	if total % n1:
		print(total)
	else:
		print(total + 1)


t = int(input())
for z in range(t):
	(n, k) = map(int, input().split())
	f = k % (n - 1)
	g = k // (n - 1)
	ans = n * g + f
	if f == 0:
		ans -= 1
	print(ans)


for _ in range(int(input())):
	(n, k) = map(int, input().split())
	i = 1
	q = k // (n - 1)
	k = k % (n - 1)
	i = n * q
	if k == 0:
		i -= 1
	i += k
	print(i)


t = int(input())
for _ in range(t):
	(n, k) = map(int, input().split())
	s2 = k % (n - 1)
	s1 = k // (n - 1)
	result = s1 * n
	if s2 == 0:
		result -= 1
	else:
		result += s2
	print(result)


for i in range(int(input())):
	(n, k) = [int(i) for i in input().split()]
	if k == 1:
		print(1)
	else:
		l = n - 1
		x = k // l
		y = k % l
		if y == 0:
			print(n * x - 1)
		else:
			print(n * x + y)


for x in range(int(input())):
	li = list(map(int, input().split()))
	in1 = li[0]
	in2 = li[1]
	mul = in2 // (in1 - 1)
	div = in2 % (in1 - 1)
	res = in1 * mul
	if div == 0:
		res -= 1
	else:
		res += div
	print(res)


import sys

def kthNonDivisible(N, K):
	L = 1
	H = sys.maxsize
	ans = 0
	while L <= H:
		mid = (L + H) // 2
		sol = mid - mid // N
		if sol > K:
			H = mid - 1
		elif sol < K:
			L = mid + 1
		else:
			ans = mid
			H = mid - 1
	return ans
t = int(input())
for i in range(t):
	test_case = input().split()
	n = int(test_case[0])
	k = int(test_case[1])
	print(kthNonDivisible(n, k))


t = int(input())
for _ in range(t):
	(n, k) = map(int, input().split(' '))
	n1 = k // (n - 1)
	n2 = k % (n - 1)
	if n2:
		print(n1 * n + n2)
	else:
		print(n1 * n + n2 - 1)


def solve(n, k):
	l = n - 1
	if k % l != 0:
		res = k // l * n + k % l
	else:
		res = (k // l - 1) * n + (n - 1)
	print(res)
t = int(input())
for i in range(t):
	(n, k) = [int(x) for x in input().split()]
	solve(n, k)


def solve(n, k):
	if k % (n - 1) == 0:
		print(k // (n - 1) * n - 1)
	else:
		print(k // (n - 1) * n + k % (n - 1))
T = int(input())
for ti in range(1, T + 1):
	(n, k) = list(map(int, input().split(' ')))
	solve(n, k)


import math
for _ in range(int(input())):
	(n, k) = map(int, input().split())
	if n == k:
		print(n + 1)
		continue
	x = k * n / (n - 1)
	if math.ceil(x) == math.floor(x):
		print(int(x - 1))
		continue
	print(math.floor(x))


from sys import stdin, stdout
import math
from itertools import permutations, combinations
from collections import defaultdict
from bisect import bisect_left
from bisect import bisect_right

def L():
	return list(map(int, stdin.readline().split()))

def In():
	return map(int, stdin.readline().split())

def I():
	return int(stdin.readline())
P = 1000000007

def main():
	for t in range(I()):
		(n, k) = In()
		d = k // (n - 1)
		r = k % (n - 1)
		if r == 0:
			print(d * n - 1)
		else:
			print(d * n + r)
main()


import math
import sys
t = int(input())
for _ in range(t):
	(n, k) = map(int, input().split())
	print((k - 1) % (n - 1) + 1 + n * ((k - 1) // (n - 1)))


for case in range(int(input())):
	(n, k) = input().split()
	(n, k) = (int(n), int(k))
	if (k + (k - 1) // (n - 1)) % n != 0:
		ans = k + (k - 1) // (n - 1)
	else:
		ans = k + (k - 1) // (n - 1) + 1
	print(ans)


for _ in range(int(input())):
	(n, k) = input().split()
	n = int(n)
	k = int(k)
	q = k // (n - 1)
	r = k % (n - 1)
	result = q * n - 1
	if r:
		result += r + 1
	print('\t', result)


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


for _ in range(int(input())):
	(n, k) = map(int, input().split())
	l = k % (n - 1)
	ans = k // (n - 1) * n + l - (not bool(l))
	print(ans)


for _ in range(int(input())):
	(n, k) = map(int, input().split())
	ans = n - 1
	divi = k // ans
	n = n * divi
	if k % ans:
		n = n + k % ans
	else:
		n -= 1
	print(n)


def run():
	import sys
	sys.stdin = open('/home/punit/Documents/Cpp Programs/input.txt', 'r')
	sys.stdout = open('/home/punit/Documents/Cpp Programs/output.txt', 'w')
	from math import ceil, sqrt, floor
for _ in range(int(input())):
	(n, k) = map(int, input().split())
	d = k % (n - 1)
	if d == 0:
		ans = k // (n - 1) * n - 1
		print(ans)
	else:
		ans = k // (n - 1) * n + int(k % (n - 1))
		print(ans)


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)


num_cases = int(input())
for case in range(num_cases):
	(divisor, num) = [int(n) for n in input().split()]
	loops = num // (divisor - 1)
	ans = loops * divisor
	if num % (divisor - 1) == 0:
		ans -= 1
	else:
		ans += num % (divisor - 1)
	print(ans)


t = int(input())
while t != 0:
	(n, k) = map(int, input().split())
	p = k / (n - 1)
	q = k % (n - 1)
	dif = 0
	if int(p) == p:
		dif = int(p) - 1
	else:
		dif = int(p)
	p = int(p)
	print((n - 1) * p + q + dif)
	t -= 1


meh = int(input())
for i in range(meh):
	(x, y) = input().split()
	if int(y) % (int(x) - 1) == 0:
		print(int(y) // (int(x) - 1) - 1 + int(y))
	else:
		print(int(y) // (int(x) - 1) + int(y))


from math import *

def some():
	test = int(input())
	for _ in range(test):
		(n, k) = map(int, input().split())
		x = n - 1
		y = k - 1
		z = floor(y / x)
		ans = z + k
		print(ans)
some()


import math
t = int(input())
for i in range(t):
	(n, k) = map(int, input().strip().split(' '))
	if k < n:
		print(k)
	else:
		g = math.ceil(k / (n - 1))
		gl = (g - 1) * n + 1
		gh = g * n - 1
		if k % (n - 1) == 0:
			print(gh)
		else:
			p = k % (n - 1)
			print(gl + p - 1)


t = int(input())
for _ in range(t):
	(n, k) = map(int, input().split())
	k -= 1
	(a, b) = (k // (n - 1), k % (n - 1))
	print(n * a + b + 1)


t = int(input())
for i in range(t):
	[n, k] = [int(x) for x in input().split()]
	r = k % (n - 1)
	if r == 0:
		r = n - 1
	print(r + n * ((k - r) // (n - 1)))


def get_num(n, k):
	lo_lim = 1
	hi_lim = k
	count = 0
	while True:
		temp = hi_lim // n - lo_lim // n
		count += temp
		lo_lim = hi_lim
		hi_lim += temp
		if temp == 0:
			break
	return k + count
t_count = int(input().strip())
while t_count > 0:
	(n, k) = list(map(int, input().strip().split(' ')))
	value = get_num(n, k)
	print(value)
	t_count -= 1


import math
t = int(input())
for _ in range(t):
	(n, k) = input().split()
	(n, k) = (int(n), int(k))
	numsMissed = math.floor((k - 1) / (n - 1))
	if (k + numsMissed) % n == 0:
		print(k + numsMissed + 1)
	else:
		print(k + numsMissed)


t = int(input())
while t > 0:
	(n, k) = [int(x) for x in input().split()]
	tt = k // (n - 1)
	ans = tt * n + k % (n - 1)
	if k % (n - 1) == 0:
		ans -= 1
	print(ans)
	t -= 1


def main(n, k):
	count = 0
	prev = 0
	k1 = k
	while True:
		val = k1 // n - prev // n
		prev = k1
		count += val
		k1 += val
		if val == 0:
			break
	return k + count
for _ in range(int(input())):
	(n, k) = [int(x) for x in input().split()]
	print(main(n, k))


t = int(input())
for _ in range(t):
	(n, k) = map(int, input().split())
	count = 0
	m = int(100000000000.0)
	a = k // (n - 1)
	b = k % (n - 1)
	if b == 0:
		print(n * a + b - 1)
	else:
		print(n * a + b)


from math import ceil
t = int(input())
while t:
	(n, k) = list(map(int, input().split()))
	if k < n:
		x = k
	elif k == n:
		x = k + 1
	else:
		s = (ceil(k / (n - 1)) - 1) * (n - 1) + (ceil(k / (n - 1)) - 1)
		x = k + s // n
	print(x)
	t -= 1


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


import math
t = int(input())
_n = []
_k = []
for i in range(t):
	inp = list(map(int, input().split()))
	_n.append(inp[0])
	_k.append(inp[1])
for _ in range(t):
	n = _n[_]
	k = _k[_]
	print((k * n - n) // (n - 1) + 1)


def one_case():
	(n, k) = map(int, input().split())
	(x, y) = (k // (n - 1), k % (n - 1))
	p = 1 if y == 0 else 0
	print(x * n + y - p)
t = int(input())
for i in range(t):
	one_case()


for ii in range(int(input())):
	(n, k) = map(int, input().split())
	cycle = n - 1
	excess = k % cycle
	no = k // cycle
	if excess != 0:
		print(excess + n * no)
	else:
		print(excess + n * no - 1)


def rec_val(k, n, q):
	if q > 0:
		m = k % n
		num = q + m
		k += q
		q = int(num / n)
		return rec_val(k, n, q)
	elif q == n:
		return k + q + 1
	else:
		return k
t = int(input())
for _ in range(t):
	(n, k) = map(int, input().split())
	q = int(k / n)
	val = rec_val(k, n, q)
	print(val)


t = int(input())
for j in range(t):
	(n, k) = map(int, input().split())
	res = (k - 1) // (n - 1) + k
	print(res)


import math
for _ in range(int(input())):
	(n, k) = map(int, input().split())
	init = k % (n - 1)
	if init == 0:
		init = n - 1
	div = k / (n - 1)
	if div % 1 == 0:
		div -= 1
	else:
		div = math.floor(div)
	res = init + n * div
	print(int(res))


T = int(input())
for i in range(T):
	(n, k) = [int(i) for i in input().split()]
	a = k % (n - 1)
	b = (k - a) / (n - 1)
	if a != 0:
		print(int(n * b + a))
	else:
		print(int(n * b + a - 1))


T = int(input())
for _ in range(T):
	(n, k) = map(int, input().split())
	mod = k % (n - 1)
	if mod == 0:
		div = k // (n - 1)
		print(div * n - 1)
		continue
	else:
		div = k // (n - 1)
		print(div * n + mod)
		continue


for _ in range(int(input())):
	(n, k) = map(int, input().split())
	rem = k // (n - 1)
	no = rem * n
	loc = rem * (n - 1)
	if loc == k:
		print(no - 1)
	else:
		no += k - loc
		print(no)


t = int(input())
for i in range(t):
	(n, k) = map(int, input().split())
	kokomade = (k + n - 2) // (n - 1) - 1
	kokomade *= n - 1
	res = ((k + n - 2) // (n - 1) - 1) * n
	res += max(0, k - kokomade)
	print(res)


testcases = int(input())
for i in range(0, testcases):
	(n, k) = map(int, input().split())
	res = n * k
	if res % (n - 1) == 0:
		res = res // (n - 1)
		print(res - 1)
	else:
		res = res // (n - 1)
		print(res)


t = int(input())
r = []
for i in range(t):
	d = input().split()
	d[0] = int(d[0])
	d[1] = int(d[1])
	n = int((d[1] - 1) / (d[0] - 1))
	r.append(d[1] + n)
for j in range(len(r)):
	print(r[j])


for _ in range(int(input())):
	(n, k) = input().split()
	g = int(k) // int(n)
	f = int(k) + g
	l = int(k)
	while l != f:
		l = f
		g = f // int(n)
		f = int(k) + g
	print(f)


t = int(input())
while t > 0:
	k = list(map(int, input().split()))
	need = (k[1] - 1) // (k[0] - 1)
	print(k[1] + need)
	t -= 1


from math import *

def solver():
	(n, k) = map(int, input().split())
	a = k
	t = 0
	pr = a // n
	while t != pr:
		a += pr - t
		t = pr
		pr = a // n
	print(a)
for _ in range(int(input())):
	solver()


from sys import stdin, stdout
cin = stdin.readline
cout = stdout.write
for _ in range(int(cin())):
	(n, k) = map(int, cin().split())
	ans = k
	l = 0
	while k >= n:
		l += k // n
		ans += k // n
		k = ans - l * n
	cout(str(ans) + '\n')


T = int(input())

def s(N, K):
	r = K % N
	a = K // N
	if r == 0:
		return s(N, a)
	else:
		pass
while T > 0:
	(N, K) = map(int, input().split())
	r = K % (N - 1)
	a = K // (N - 1)
	print(a * N + r - (0 if r > 0 else 1))
	T -= 1


test = int(input())
test_arr = []

def ret_last(n, num, last):
	new = int(num / n)
	if new > last:
		num = ret_last(n, num + (new - last), new)
	return num
for _ in range(test):
	(n, k) = map(int, input().split(' '))
	k_ = int(k / n)
	num = k
	if k_ > 0:
		num = ret_last(n, k + k_, k_)
	test_arr.append(num)
for t in test_arr:
	print(t)


from math import ceil
tc = int(input())
for zzz in range(tc):
	(n, k) = map(int, input().split())
	l = ceil(k / (n - 1))
	bg = n * (l - 1)
	mg = (n - 1) * (l - 1)
	ans = bg + (k - mg)
	print(ans)


from math import ceil
TC = int(input())
for i in range(TC):
	(n, k) = map(int, input().split())
	jump = k // (n - 1)
	intercept = k % (n - 1)
	if intercept == 0:
		jump -= 1
		intercept += n - 1
	print(jump * n + intercept)


from sys import *
from collections import *
from math import *
input = stdin.readline
tc = int(input())
for tcase in range(tc):
	(n, k) = map(int, input().split())
	lo = 1
	hi = 10 ** 19
	ans = -1
	while lo <= hi:
		mid = (lo + hi) // 2
		divi = mid - mid // n
		if divi >= k:
			ans = mid
			hi = mid - 1
		else:
			lo = mid + 1
	print(ans)


import math
t = int(input())
for _ in range(t):
	(n, k) = map(int, input().split())
	res = k // (n - 1)
	resto = k % (n - 1)
	if resto == 0:
		print(n * res - 1)
	else:
		print(n * res + resto)


t = int(input())

def solve(n, k):
	p = k // (n - 1) + (k % (n - 1) > 0)
	start = (p - 1) * n + 1
	k -= (p - 1) * (n - 1)
	ans = start + k - 1
	return ans
while t:
	t -= 1
	(n, k) = list(map(int, input().split(' ')))
	print(solve(n, k))


import sys

def gun(a, b):
	if a == 0:
		return b
	return gun(b % a, a)

def fun(a, n):
	l = 1
	h = sys.maxsize
	while l < h:
		mid = l + (h - l) // 2
		if mid - mid // a < n:
			l = mid + 1
		else:
			h = mid
	print(l)
t = int(input())
for i in range(t):
	(a, n) = map(int, input().split())
	fun(a, n)


t = int(input())
for _ in range(t):
	nk = list(map(int, input().split()))
	n = nk[0]
	k = nk[1]
	np = n - 1
	tup = divmod(k, np)
	sets = tup[0]
	r = tup[1]
	tot = sets * n - 1
	if r > 0:
		tot += r + 1
	print(tot)


T = int(input())
for test in range(T):
	(n, k) = map(int, input().split())
	t1 = k // n
	while True:
		t2 = (k + t1) // n
		if t1 == t2:
			break
		t1 = t2
	print(t1 + k)


from math import *
t = int(input())
while t > 0:
	(n, k) = [int(x) for x in input().split()]
	l = k // n
	d = k // n
	ans = k
	while l > 0:
		k = k + l
		l = k // n - d
		d = k // n
	print(k)
	t -= 1


import math
t = int(input())
for i in range(t):
	(N, K) = map(int, input().split())
	aaa = N
	x111 = math.ceil(K / (N - 1))
	y222 = 1 + (x111 - 1) * aaa
	ans333a = (x111 - 1) * (aaa - 1)
	zzz = 0
	p = zzz + 8
	ans333a += 1
	ans333a = K - ans333a
	ans333a += y222
	print(ans333a)


import sys
import os.path

def solve():
	T = int(input())
	for tests in range(T):
		(n, k) = map(int, input().split())
		if k < n:
			print(k)
		else:
			x = int(k / (n - 1))
			if x * (n - 1) < k:
				x += 1
			k %= n - 1
			if k == 0:
				k = n - 1
			print((x - 1) * n + k)

def main():
	if os.path.exists('test.inp'):
		sys.stdin = open('test.inp', 'r')
	solve()
main()


def gcd(n, m):
	return m - m // n
for i in range(int(input())):
	(n, k) = input().split()
	n = int(n)
	k = int(k)
	l = k
	r = n * k
	while l < r:
		middle = (l + r) // 2
		if gcd(n, middle) >= k:
			r = middle
		else:
			l = middle + 1
	print(r)


for _ in range(int(input())):
	(n, k) = list(map(int, input().split()))
	mul = k // (n - 1)
	div = k % (n - 1)
	res = n * mul
	if div == 0:
		res -= 1
	else:
		res += div
	print(res)


t = int(input())
for _ in range(t):
	(n, k) = list(map(int, input().split()))
	need = (k - 1) // (n - 1)
	print(k + need)


for _ in range(int(input())):
	(n, k) = input().split()
	n = int(n)
	k = int(k)
	res = k
	while k >= n:
		a = k // n
		b = k % n
		res += a
		k = a + b
	print(res)


k = int(input())
for k0 in range(k):
	(n, k) = map(int, input().split())
	z = (k - 1) // (n - 1)
	ost = k - z * (n - 1)
	print(z * n + ost)


def kth_search(low, high, n, k):
	mid = (low + high) // 2
	count = mid - mid // n
	if low > high:
		return int(low)
	if count >= k:
		return kth_search(low, mid - 1, n, k)
	else:
		return kth_search(mid + 1, high, n, k)
t = int(input())
for i in range(t):
	(n, k) = map(int, input().split())
	print(kth_search(1, 1000000000000.0, n, k))


for _ in range(int(input())):
	(n, k) = map(int, input().split())
	temp = 0
	while 1:
		div = k // n
		diff = div - temp
		if temp == div:
			break
		k += diff
		temp = div
	print(k)


for _ in range(int(input())):
	(n, k) = map(int, input().split())
	no_of_sets = k // (n - 1)
	k_th_not_div = no_of_sets * (n - 1)
	last_div_no = no_of_sets * n
	if k_th_not_div == k:
		last_div_no -= 1
	else:
		last_div_no += k - k_th_not_div
	print(last_div_no)


t = int(input())
for i in range(t):
	(n, k) = map(int, input().split())
	q1 = k // n
	q2 = (k + k // n) // n
	ans = k // n + k
	while q2 - q1 != 0:
		ans += q2 - q1
		q1 = q2
		q2 = ans // n
	print(ans)


import sys, os
from io import BytesIO, IOBase
import collections, itertools, bisect, heapq, math, string
BUFSIZE = 8192
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
input = lambda : sys.stdin.readline().rstrip('\r\n')

def main():
	t = int(input())
	num = []
	for i in range(t):
		nk = list(map(int, input().split()))
		num.append(nk)
	for i in range(t):
		(n, k) = (num[i][0], num[i][1])
		if k < n:
			print(k)
		else:
			m = k % (n - 1)
			x = k // (n - 1)
			if m == 0:
				print(x * n - 1)
			else:
				print(x + k)
main()


from sys import stdin, stdout
for _ in range(int(stdin.readline())):
	(n, k) = map(int, stdin.readline().split())
	if k % (n - 1) != 0:
		ans = k % (n - 1) + n * (k // (n - 1))
	else:
		ans = k // (n - 1) * n - 1
	stdout.write(str(ans) + '\n')


_testcount = int(input())
for i in range(_testcount):
	(k, n) = map(int, input().split())
	skip = n // (k - 1)
	rem = n - skip * (k - 1)
	if rem != 0:
		res = k * skip + rem
	else:
		res = skip * k - 1
	print(res)


t = int(input())

def bf(n, k):
	cnt = 0
	for i in range(1, 10 ** 10):
		if i % n != 0:
			cnt += 1
		if cnt == k:
			return i
for _ in range(t):
	(n, k) = list(map(int, input().split()))
	low = 0
	high = 10 ** 10
	while low < high:
		mid = low + (high - low) // 2
		target = mid - mid // n
		if target == k:
			if mid % n == 0:
				if mid - 1 - (mid - 1) // n == k:
					print(mid - 1)
				else:
					print(mid + 1)
			else:
				print(mid)
			break
		elif target > k:
			high = mid
		else:
			low = mid


t = int(input())
import math
while t > 0:
	t -= 1
	(n, k) = [int(x) for x in input().split()]
	numsets = math.ceil(k / (n - 1))
	if k % (n - 1) == 0:
		print((numsets - 1) * n + n - 1)
	else:
		print((numsets - 1) * n + k % (n - 1))


import math
for _ in range(int(input())):
	(a, b) = input().split()
	a = int(a)
	b = int(b)
	c = b / a
	d = b + c
	while c > 1:
		c = c / a
		d += c
	print(math.floor(d))


u = int(input())
while u:
	(n, k) = map(int, input().split(' '))
	if k % (n - 1) == 0:
		x = int(k / (n - 1)) - 1
	else:
		x = int(k / (n - 1))
	print(k + x)
	u -= 1


t = int(input())
for _ in range(t):
	(n, k) = map(int, input().split())
	gr = k / (n - 1)
	if int(gr) == gr:
		gr = int(gr)
	else:
		gr = int(gr) + 1
	p = (gr - 1) * (n - 1)
	print(n * (gr - 1) + (k - p))


def ost(a, b, x):
	s = a // b
	if s > 0:
		return ost(s + a % b, b, x + s)
	else:
		return x
t = int(input())
for trying in range(t):
	(n, k) = list(map(int, input().split()))
	if k < n:
		print(k)
	else:
		print(k + ost(k, n, 0))


from math import ceil
for t in range(int(input())):
	(n, k) = list(map(int, input().split()))
	x = n + (k // (n - 1) - 1) * n
	z = k // (n - 1) * (n - 1)
	if z == k:
		print(x - 1)
	else:
		print(x + (k - z))


import math

def binary_search(n, k):
	l = 1
	r = 10000000000.0
	m = -1
	res = -1
	while r >= l:
		m = l + math.trunc((r - l) / 2)
		if m - math.floor(m / n) >= k:
			r = m - 1
			if m % n != 0:
				res = m
		elif m - math.floor(m / n) < k:
			l = m + 1
	return res
t = int(input())
for i in range(t):
	(n, k) = [int(x) for x in input().split()]
	print(binary_search(n, k))


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


import math
t = int(input())
while t:
	(n, k) = map(int, input().split())
	m = n - 1
	ans = k // m * n
	if k % m == 0:
		ans -= 1
	else:
		ans += k % m
	print(ans)
	t -= 1


for i in range(int(input())):
	(n, k) = [int(x) for x in input().split()]
	q = int(k / (n - 1))
	r = k % (n - 1)
	if r != 0:
		print(q * n + r)
	else:
		print(q * n - 1)


import math
t = int(input())
for i in range(t):
	l1 = input()
	l = l1.split()
	n = int(l[0])
	k = int(l[1])
	print()
	if k < n:
		print(k)
	else:
		p = k / (n - 1)
		q = n * p
		if k % (n - 1) != 0:
			if int(q) - int(p) == k:
				print(math.floor(q))
			else:
				print(math.ceil(q))
		else:
			print(int(p * n - 1))


def main():
	for _ in range(int(input())):
		(k, n) = map(int, input().split())
		if n < k:
			print(n)
		else:
			x = n // (k - 1)
			x = x + x * (k - 1)
			print(x - 1 if n % (k - 1) == 0 else x + n % (k - 1))
main()


t = int(input())
for i in range(1, t + 1):
	l = list(map(int, input().split()))
	n = l[0]
	k = l[1]
	print((k - 1) // (n - 1) + k)


x = int(input())
for i in range(x):
	(n, k) = map(int, input().split())
	if k == 1:
		print(1)
	else:
		p = n - 1
		l = (k - 1) // p
		l2 = (k - 1) % p
		o = l * n
		o += 1
		if l2 == n - 1:
			o += 2
		elif l2 == 0:
			o = o
		else:
			o += l2 * 1
		print(o)


def solve(n, k):
	if k == 1:
		return 1
	c = k // (n - 1)
	d = k % (n - 1)
	if d == 0:
		d -= 1
	r = n * c + d
	return r
t = int(input())
for _ in range(t):
	(a, b) = list(map(int, input().split()))
	r = solve(a, b)
	print(r)


from math import floor
tt = int(input())
for t in range(tt):
	(n, k) = map(int, input().split())
	rmin = 0
	rmax = k
	last = k
	while True:
		skipped = int(floor(rmax / n)) - int(floor(rmin / n))
		if skipped == 0:
			break
		rmin = rmax
		rmax += skipped
	print(rmax)


t = int(input())
for i in range(t):
	(n, k) = input().split()
	n = int(n)
	k = int(k)
	aux = k // n
	while aux != 0:
		m = k % n
		k = k + aux
		aux = aux + m
		aux = aux // n
	print(k)


def Bsolu(h, l, n, k):
	while l < h:
		m = int(l + (h - l) / 2)
		if m - m // n >= k:
			if m % n != 0:
				result = m
			h = m
		else:
			l = m + 1
	return result
for i in range(int(input())):
	(n, k) = map(int, input().split())
	h = 10 ** 10
	l = 1
	print(Bsolu(h, l, n, k))


import sys
input = sys.stdin.readline
for _ in range(int(input())):
	(n, k) = map(int, input().split())
	print((n * k - 1) // (n - 1))


def f():
	T = int(input())
	for _ in range(T):
		(n, k) = [int(c) for c in input().split()]
		print(solve_bsearch(n, k))

def solve(n, k):
	return k + (k - 1) // (n - 1)

def solve_bsearch(n, k):
	left = 1
	right = 2 ** 32
	while left < right:
		mid = (left + right) // 2
		non_divisable_cnt = mid - mid // n
		if k <= non_divisable_cnt:
			right = mid
		else:
			left = mid + 1
	return left
f()


t = int(input())

def check(ans, n, k):
	return ans - int(ans / n) == k
while t:
	[n, k] = [int(x) for x in input().split()]
	ans = int(n * k / (n - 1))
	while check(ans - 1, n, k):
		ans -= 1
	print(ans)
	t -= 1


def next(a, b):
	n = int(b / (a - 1))
	r = b % (a - 1)
	if r == 0:
		print(a * n - 1)
	else:
		print(a * n + r)
	return
m = int(input())
for t in range(m):
	(a, b) = map(int, input().split())
	next(a, b)


for i in range(int(input())):
	(n, k) = input().split()
	n = int(n)
	k = int(k)
	if k % (n - 1) == 0:
		solution = n * (k // (n - 1)) - 1
	else:
		solution = n * (k // (n - 1)) + k % (n - 1)
	print(solution)


T = int(input())
for t in range(T):
	(n, k) = list(map(int, input().split()))
	if k <= n - 1:
		print(k)
	elif n == k:
		print(n + 1)
	else:
		x = k // (n - 1)
		if k % (n - 1) == 0:
			res = res = x * n - 1
		else:
			num_previous_blocs = x * (n - 1)
			res = x * n + (k - num_previous_blocs)
		print(res)


from fractions import Fraction
import sys
import bisect
import heapq
from math import *
from collections import Counter as counter
from itertools import combinations as comb
from itertools import permutations as permutate
from bisect import bisect_left as bl
from bisect import bisect_right as br
from bisect import bisect
mod = 1000000007

def inp():
	return sys.stdin.readline().strip()

def out(var):
	sys.stdout.write(str(var))

def lis():
	return list(map(int, inp().split()))

def stringlis():
	return list(map(str, inp().split()))

def sep():
	return map(int, inp().split())

def strsep():
	return map(str, inp().split())

def graph(vertex):
	return [[] for i in range(0, vertex + 1)]

def zerolist(n):
	return [0] * n

def nextline():
	out('\n')

def testcase(t):
	for p in range(t):
		solve()

def printlist(a):
	for p in range(0, len(a)):
		out(str(a[p]) + ' ')

def lcm(a, b):
	return a * b // gcd(a, b)

def power(a, b):
	ans = 1
	while b > 0:
		if b % 2 == 1:
			ans *= a
		a *= a
		b //= 2
	return ans
for i in range(int(input())):
	(n, k) = map(int, input().split())
	l = 1
	r = 2 * k
	a = 0
	while l <= r:
		m = (l + r) // 2
		if m - m // n >= k:
			a = m
			r = m - 1
		else:
			l = m + 1
	print(a)


def KthNotDivisibleByN(n: int, k: int) -> None:
	if k < n:
		print(k)
		return
	print(int((k * n - 1) / (n - 1)))
	return
test_cases = int(input())
for i in range(test_cases):
	inputs = input().split()
	KthNotDivisibleByN(int(inputs[0]), int(inputs[1]))


def read_tokens():
	return input().strip().split(' ')

def read_ints():
	return [int(s) for s in read_tokens()]
T = int(input())

def solve(n: int, k: int) -> int:
	bad = 0
	good = 10 ** 18
	while good - bad > 1:
		m = (good + bad) // 2
		if m - m // n >= k:
			good = m
		else:
			bad = m
	return good
for test in range(T):
	(n, k) = read_ints()
	ans = solve(n, k)
	print(ans)


import sys
input = sys.stdin.readline
for T in range(int(input())):
	(n, k) = map(int, input().split())
	if k % (n - 1) == 0:
		print(n * (k // (n - 1)) - 1)
	else:
		print(n * (k // (n - 1)) + k % (n - 1))


from sys import stdin, stdout
t = int(input())
for z in range(t):
	(n, k) = map(int, input().rstrip().split())
	m = k // (n - 1) * n + k % (n - 1)
	if n > k:
		stdout.write(f'{k}\n')
	elif k % (n - 1) == 0:
		stdout.write(f'{m - 1}\n')
	else:
		stdout.write(f'{m}\n')


t = int(input())
for i in range(t):
	(n, k) = map(int, input().split())
	s = k + k // n
	c = 0
	while s // n - k // n != 0:
		l = s
		s = s + (s // n - k // n)
		k = l
	print(s)


from bisect import bisect_left, bisect_right
INF = 1 << 60
t = int(input())
for i in range(t):
	(n, k) = map(int, input().split())
	print(k + (k - 1) // (n - 1))


t = int(input())
z = t
a = list()
ans = list()
while z > 0:
	str1 = input()
	a = str1.split()
	n = int(a[0])
	k = int(a[1])
	w = k * n / (n - 1)
	w = w - 1
	if k * n % (n - 1) == 0:
		ans.append(int(w))
	else:
		ans.append(int(w + 1))
	z = z - 1
for r in ans:
	print(r)
1


def fun(n, k):
	import math
	x = math.ceil(k / (n - 1)) - 1
	return x * n + (k - x * (n - 1))
for _ in range(int(input())):
	(a, b) = [int(x) for x in input().split()]
	print(fun(a, b))


def inp():
	return int(input())

def inlt():
	return list(map(int, input().split()))

def insr():
	s = input()
	return list(s[:len(s) - 1])

def invr():
	return map(int, input().split())
entries = inp()
for i in range(entries):
	ins = inlt()
	n = ins[0]
	k = ins[1]
	res = k + int(k / (n - 1))
	if k % (n - 1) == 0:
		res -= 1
	print(str(res))


def resultado(n, k):
	div = k // (n - 1)
	if k % (n - 1) == 0:
		div -= 1
	return k + div
qnt = int(input())
for _ in range(qnt):
	(n, k) = list(map(int, input().split()))
	print(resultado(n, k))


t = int(input())
for i in range(t):
	(n, k) = map(int, input().split())
	count = 0
	z = n
	count = count + k // z
	z = k // z + k % z
	while z >= n:
		count = count + z // n
		z = z // n + z % n
	print(count + k)


for i in range(int(input())):
	(a, b) = list(map(int, input().split()))
	n = b
	p = 0
	while n >= a:
		p += n // a
		n = n % a + n // a
	print(b + p)


n = int(input())
for i in range(n):
	(n, k) = map(int, input().split())
	group = n - 1
	ans_1 = k // group
	ans_2 = k % group
	if ans_2 == 0:
		ans_itog = ans_1 * n - 1
	else:
		ans_itog = ans_1 * n + ans_2
	print(ans_itog)


t = int(input())
while t > 0:
	(n, k) = map(int, input().split())
	batches = k // (n - 1)
	mods = k % (n - 1)
	ans = n - 1 + (batches - 1) * n
	if mods > 0:
		ans += 1
		ans += mods
	print(ans)
	t -= 1


t = int(input())
for i in range(0, t):
	a = input().split()
	b = eval(a[0])
	c = eval(a[1])
	d = c // (b - 1)
	e = (b - 1) * d
	f = c % (b - 1)
	if e == c:
		g = b * d - 1
	else:
		g = b * d
	while e != c:
		e += f
		g += f
	print(g)


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


t = int(input())
while t:
	(n, k) = map(int, input().split())
	a = k % (n - 1)
	b = k // (n - 1)
	c = n * b
	if a == 0:
		res = c - 1
	else:
		res = c + a
	print(res)
	t -= 1


for s in [*open(0)][1:]:
	(n, k) = map(int, s.split())
	print((k - 1) // (n - 1) + k)


T = int(input())
for t in range(T):
	(N, K) = map(int, input().strip().split(' '))
	ans = (K - 1) // (N - 1)
	print(K + ans)


t = int(input())
for i in range(t):
	(n, k) = map(int, input().split())
	boost = n - 1
	mul = k // boost
	ans = n * mul
	if k == mul * boost:
		print(ans - 1)
	else:
		inc = k - mul * boost
		print(ans + inc)


for _ in range(int(input())):
	(n, k) = list(map(int, input().split()))
	o1 = k
	start1 = 0
	start2 = o1 // n
	o2 = o1
	while o2 >= (start1 + 1) * n:
		o1 = o2
		o2 += start2 - start1
		start2 = o2 // n
		start1 = o1 // n
	print(o2)


q = int(input())
for i in range(q):
	(n, k) = [int(i) for i in input().split()]
	t = k + k // n
	last = k
	while last < t:
		div = t - last + last % n
		last = t
		t += div // n
	print(t)


def f(x, n):
	return x // n

def ff(l, r, n):
	return f(r, n) - f(l - 1, n)
for _ in range(int(input())):
	(n, k) = map(int, input().split())
	k -= 1
	s = 1
	while k > 0:
		nk = ff(s, s + k, n)
		s += k
		k = nk
		if s % n == 0:
			s -= 1
		if k == 1:
			k = 0
			s += 1
			if s % n == 0:
				s += 1
	print(s)


test = int(input())
for i in range(test):
	(n, k) = [int(i) for i in input().split()]
	jump = n - 1
	if k < n:
		rank = k
	else:
		rank = k + int((k - 1) // (n - 1))
	print(rank)


t = int(input())
import math

def solve(n, k):
	return k + int((k - 1) / (n - 1))
for _ in range(t):
	(n, k) = [int(x) for x in input().strip().split()]
	print(solve(n, k))


import math

def KthNotDivisiblebyN(n: int, k: int) -> int:
	factor = math.floor(k / (n - 1))
	remainder = k % (n - 1)
	if remainder == 0:
		return n * factor - 1
	else:
		return n * factor + remainder
t = int(input())
Result = list()
for i in range(t):
	(number, position) = map(int, input().split())
	Result.append(KthNotDivisiblebyN(number, position))
for x in Result:
	print(x)


t = int(input())
saida = []
for i in range(t):
	entrada = input().split()
	n = int(entrada[0])
	k = int(entrada[1])
	s = 0
	if k < n:
		s = k
	elif k == n:
		s = k + 1
	else:
		l = 0
		r = k * 2
		while l < r:
			m = int((l + r) / 2)
			if m == l or m == r:
				break
			if int(m / n) > m - k:
				l = m
			elif int(m / n) < m - k:
				r = m
			else:
				s = m
				r = m
	saida.append(s)
for h in saida:
	print(h)


import math
T = int(input())
for i in range(T):
	(n, k) = map(int, input().split())
	x = (k - 1) // (n - 1)
	print(k + x)


for _ in range(int(input())):
	(n, k) = map(int, input().split())
	interval_length = n - 1
	p = k // interval_length
	if k % interval_length == 0:
		print(p * n - 1)
	else:
		print(p * n + k % interval_length)


t = int(input())
while t:
	(a, b) = map(int, input().split())
	c = b // (a - 1)
	if (c + b) % a == 0:
		print(b + c - 1)
	else:
		print(b + c)
	t = t - 1


import math

def divs(n, k):
	print(k + math.floor((k - 1) / (n - 1)))
import os
import sys
input = sys.stdin.readline
t = int(input())
for _ in range(t):
	(n, k) = map(int, input().split())
	divs(n, k)


for i in range(int(input())):
	(n, k) = map(int, input().split())
	divi = k // (n - 1)
	rem = k % (n - 1)
	if rem != 0:
		print(n * divi + rem)
	else:
		print(n * divi - 1)


def brute(n, k):
	seen = 0
	x = 0
	while True:
		x += 1
		if x % n != 0:
			seen += 1
		if seen == k:
			return x

def soln(n, k):
	c = k // (n - 1)
	ans = k + c
	if k % (n - 1) == 0:
		ans -= 1
	return ans

def main():
	t = int(input())
	for _ in range(t):
		(n, k) = [int(x) for x in input().split(' ')]
		result = soln(n, k)
		print(result)
main()


def s():
	(n, k) = [int(x) for x in input().split(' ')]
	if n > k:
		print(k)
	else:
		period = k // (n - 1)
		temp2 = period * n
		if k % (n - 1) != 0:
			temp2 = temp2 + k - (n - 1) * period
		else:
			temp2 -= 1
		print(temp2)
t = int(input())
for i in range(t):
	s()


from sys import stdin, stdout
import math

def main():
	t = int(stdin.readline())
	for _ in range(t):
		(n, k) = list(map(int, stdin.readline().split()))
		if n > k:
			stdout.write(str(k) + '\n')
			continue
		ans = math.ceil(k / (n - 1)) - 1
		stdout.write(str(k + ans) + '\n')
main()


for k in range(int(input())):
	(n, s) = map(int, input().split())
	u = round((s - 1) // (n - 1))
	print(s + u)


def solve():
	(n, k) = map(int, input().split())
	res = k
	(d, r) = divmod(k, n)
	while d:
		res += d
		(d, r) = divmod(d + r, n)
	print(res)
for _ in range(int(input())):
	solve()


t = int(input())
for i in range(t):
	(n, k) = map(int, input().split(' '))
	m = n - 1
	r = k / m
	f = k // m
	if r > f:
		rv = f * n + (k - f * m)
		print(int(rv))
	else:
		print(int(n * f - 1))


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


import math
t = int(input(''))
for i in range(0, t):
	(n, k) = map(int, input('').split(' '))
	if k <= n - 1:
		print(k)
		continue
	seq = math.ceil(k / (n - 1))
	orderInSeq = (k - 1) % (n - 1)
	divisibleNum = n * (seq - 1)
	print(divisibleNum + orderInSeq + 1)


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

	def f(x):
		return x - x // n
	(lo, hi) = (0, 10 ** 12)
	while lo < hi:
		mi = lo + hi >> 1
		if f(mi) < k:
			lo = mi + 1
		else:
			hi = mi
	print(lo)


import math
for _ in range(int(input())):
	taken_input = input().split()
	n = int(taken_input[0])
	k = int(taken_input[1])
	sets_of_not_included = math.ceil(k / (n - 1))
	position_in_set = k % (n - 1)
	if position_in_set == 0:
		position_in_set = n - 1
	answer = (sets_of_not_included - 1) * n + position_in_set
	print(answer)


from sys import stdin, stdout
t = int(stdin.readline())
while t > 0:
	(n, k) = map(int, stdin.readline().split())
	if n > k:
		stdout.write('{}\n'.format(k))
	elif n == k:
		stdout.write('{}\n'.format(k + 1))
	else:
		ans = 0
		r = k % (n - 1)
		q = k // (n - 1)
		if r == 0:
			ans = n * q - 1
		else:
			ans = n * q + r
		stdout.write('{}\n'.format(ans))
	t -= 1


ts = int(input())
for _ in range(ts):
	(n, k) = tuple([int(x) for x in input().split(' ')])
	x = k
	d = k // n
	cum_d = k // n
	while d > 0:
		x = x + d
		d = x // n - cum_d
		cum_d += d
	print(x)


def readInt():
	return int(input())

def readList():
	return list(map(int, input().rstrip().split()))

def readString():
	s = input()
	return s

def readInts():
	return map(int, input().rstrip().split())

def solve(n, k):
	if k <= n - 1:
		print(k)
	else:
		r = k // (n - 1)
		m = k % (n - 1)
		if m == 0:
			print(r * n - 1)
		else:
			print(r * n + m)
t = readInt()
for i in range(t):
	(n, k) = readInts()
	solve(n, k)


T = int(input())
while T:
	(n, k) = map(int, input().split())
	x = k // n
	k = k + x
	y = k // n
	p = x
	while y - x > 0:
		x = k // n
		k = k + x - p
		y = k // n
		p = x
	print(k)
	T = T - 1


import math
tt = int(input())
while tt:
	(n, k) = [int(x) for x in input().split()]
	pp = math.floor(k / (n - 1))
	k -= pp * (n - 1)
	i = n * pp
	if k % (n - 1) == 0:
		print(k + i - 1)
	else:
		print(k + i)
	tt -= 1


from pprint import pprint
import sys
input = sys.stdin.readline
import math
q = int(input())
for _ in range(q):
	(n, k) = map(int, input().split())
	x = math.ceil((k - 1) // (n - 1))
	res = n * x
	amari = k - (n - 1) * x
	res += amari
	print(res)


import sys, math, cmath, time
start_time = time.time()
tt = 0

def inp():
	return int(input())

def inlt():
	return list(map(int, input().split()))

def insr():
	return input().strip()

def invr():
	return map(int, input().split())

def solve():
	(n, k) = invr()
	print(k + (k - 1) // (n - 1))

def main():
	if not ONLINE_JUDGE:
		sys.stdin = open('input.txt', 'r')
		sys.stdout = open('output.txt', 'w')
	t = 1
	t = inp()
	for tt in range(t):
		solve()
	if not ONLINE_JUDGE:
		print('Time Elapsed :', time.time() - start_time, 'seconds')
	sys.stdout.close()

def counter(a):
	q = [0] * max(a)
	for i in range(len(a)):
		q[a[i] - 1] = q[a[i] - 1] + 1
	return q

def string_counter(a):
	q = [0] * 26
	for i in range(len(a)):
		q[ord(a[i]) - 97] = q[ord(a[i]) - 97] + 1
	return q
ONLINE_JUDGE = __debug__
if ONLINE_JUDGE:
	input = sys.stdin.readline
main()


for _ in range(int(input())):
	(N, K) = map(int, input().split())
	if K % (N - 1) == 0:
		print(N * int(K // (N - 1)) - 1)
	else:
		Mul = int(K // (N - 1))
		Num = N * Mul
		Add = K % (N - 1)
		print(Num + Add)


import math as m
t = int(input())
for _ in range(t):
	(n, k) = map(int, input().split())
	if k % (n - 1) == 0:
		y = k // (n - 1)
		print(y * n - 1)
	else:
		x = m.floor(k / (n - 1))
		z = x * n + k % (n - 1)
		print(z)


import math
t = int(input())
for i in range(t):
	(n, k) = map(int, input().split())
	r = n * k
	p = math.floor(r / (n - 1))
	if p % n == 0:
		print(p - 1)
	else:
		print(p)


t = int(input())
l = []
for i in range(t):
	(n, k) = list(map(int, input().split()))
	div = k // (n - 1)
	ex = k % (n - 1)
	ans = n * div + ex
	if ex == 0:
		ans -= 1
	print(ans)


N = int(input())
for _ in range(N):
	(x1, y1) = map(int, input().split())
	if y1 < x1:
		print(y1)
	elif x1 == y1:
		print(y1 + 1)
	else:
		z = y1 % (x1 - 1)
		if z == 0:
			print(y1 + y1 // (x1 - 1) - 1)
		else:
			print(y1 + y1 // (x1 - 1))


n = int(input())
for i in range(n):
	(a, b) = map(int, input().split())
	t = b
	while t - t // a != b:
		t += b - (t - t // a)
	print(t)


t = int(input())
for _ in range(t):
	(n, k) = map(int, input().split())
	r = k % n
	q = k // n
	b = q
	while True:
		k += q
		q = k // n
		q -= b
		b += q
		if q == 0:
			break
	print(k)


for _ in range(int(input())):
	(n, k) = map(int, input().split())
	aa = k // (n - 1)
	w = n * aa - aa
	while w < k:
		aa += 1
		w = n * aa - aa
	xx = w - k
	print(n * aa - xx - 1)


def main():
	(n, k) = map(int, input().split())
	res = n * (k // (n - 1)) + (k % (n - 1) if k % (n - 1) else -1)
	print(res)
for _ in range(int(input())):
	main()


numcases = int(input())
for i in range(numcases):
	(n, k) = map(int, input().split())
	ans = k
	old = 0
	new = k // n
	while True:
		ans = ans + new - old
		old = new
		new = ans // n
		if old == new:
			break
	print(ans)


for uio in range(int(input())):
	(n, k) = map(int, input().split())
	print((int(k / (n - 1)) * n + k % (n - 1), int(k / (n - 1)) * n - 1)[k % (n - 1) == 0])


t = int(input())
for _ in range(t):
	(n, k) = map(int, input().split())
	ans = k
	divs = k // n
	if n == 2:
		ans = 2 * k - 1
		print(ans)
		continue
	left = divs
	prevans = ans
	while left != 0:
		ans += left
		left = ans // n - prevans // n
		prevans = ans
	while ans % n == 0:
		ans += 1
	print(ans)


def solve(n, k):
	q = int(k // n)
	while True:
		if (k + q) // n == q:
			q = (k + q) // n
			return k + q
			break
		else:
			q = (k + q) // n
t = int(input())
output = []
for i in range(t):
	(n, k) = [int(x) for x in input().split()]
	output.append(solve(n, k))
for m in output:
	print(m)


def to_list(s):
	return list(map(lambda x: int(x), s.split(' ')))

def solve(n, k):
	not_n = n - 1
	ost = k % not_n
	full = int(k / not_n)
	if ost != 0:
		return str(k // (n - 1) * n + k % (n - 1))
	else:
		return str(full * n - 1)
t = int(input())
answers = []
for i in range(t):
	(n, k) = to_list(input())
	answers.append(solve(n, k))
print('\n'.join(answers))


import math
t = int(input())
for r in range(t):
	S = list(map(int, input().split()))
	n = S[0]
	k = S[1]
	if n * k % (n - 1) != 0:
		print(math.floor(n * k / (n - 1)))
	else:
		print(math.floor(n * k / (n - 1)) - 1)


a = int(input())
for i in range(a):
	(n, k) = map(int, input().split())
	total = n - 1
	sets = k // total
	rem = k % total
	tem = sets * n
	if rem == 0:
		print(tem - 1)
		continue
	print(tem + rem)


def iinput():
	return [int(i) for i in input().split()]
t = int(input())
for _ in range(t):
	(n, k) = iinput()
	ostatok = k % (n - 1)
	if ostatok == 0:
		ostatok -= 1
	pos = k // (n - 1)
	print(pos * n + ostatok)


t = int(input())
while t != 0:
	t -= 1
	(n, k) = map(int, input().split())
	a = k // (n - 1)
	b = k % (n - 1)
	if k < n:
		print(k)
	elif n == 2:
		print(2 * k - 1)
	elif b == 0:
		print(n * (a + 1) - n + b - 1)
	else:
		print(n * (a + 1) - (n - b))


for _ in range(int(input())):
	(n, k) = map(int, input().split())
	cnt = 1
	cnt2 = 1
	y = k // n
	a = k - y * n
	while y + a >= n:
		cnt = y + a
		cnt2 = y
		y = cnt // n
		a = cnt - y * n
		k += cnt2
	k += y
	print(k)


import math

def facts(n):
	ans = []
	for i in range(2, int(math.sqrt(n) + 1)):
		if n % i == 0:
			ans.append(i)
			ans.append(n // i)
	ans = sorted(ans)
	return ans
for _ in range(int(input())):
	(n, k) = map(int, input().split())
	left = 1
	right = int(10000000000.0)
	while left < right:
		mid = (left + right) // 2
		if mid - mid // n > k:
			right = mid
		else:
			left = mid + 1
	ans = left - 1
	if ans % n == 0:
		ans -= 1
	print(ans)


t = int(input())
n = []
k = []
for i in range(t):
	(inpn, inpk) = map(int, input().split())
	n.append(inpn)
	k.append(inpk)
for i in range(t):
	if k[i] % (n[i] - 1) == 0:
		print(k[i] // (n[i] - 1) * n[i] - 1)
	else:
		print(k[i] // (n[i] - 1) * n[i] + k[i] % (n[i] - 1))


t = int(input())
for _ in range(t):
	(n, k) = map(int, input().split())
	ind = k // (n - 1)
	r = k % (n - 1)
	ans = n * ind + r
	if r == 0:
		ans -= 1
	print(ans)


t = int(input())
i = 0
while i < t:
	(n, k) = map(int, input().split())
	sizeofset = n - 1
	noofset = k // (n - 1)
	remainder = k % (n - 1)
	count = 0
	count = noofset * n - 1
	if remainder != 0:
		count = count + remainder + 1
	print(count)
	i = i + 1


for t in range(int(input())):
	(n, k) = map(int, input().split())
	sz = n - 1
	shifts = (k - 1) // sz
	st = n * shifts + 1
	index = k - 1 - sz * shifts
	ans = st + index
	print(ans)


t = int(input())
while t > 0:
	(a, b) = map(int, input().split())
	sol = b // (a - 1) * a + b % (a - 1)
	if b % (a - 1) == 0:
		sol = sol - 1
	print(sol)
	t = t - 1


MOD = 1000000007

def solve(n, k):
	if n == 2:
		ans = 2 * k - 1
	elif k % (n - 1) == 0:
		ans = n * (k // (n - 1)) - 1
	else:
		ans = n * (k // (n - 1)) + k % (n - 1)
	print(ans)
for i in range(int(input())):
	(n, k) = map(int, input().split())
	solve(n, k)


def rs():
	return input().strip()

def ri():
	return int(input())

def ria():
	return list(map(int, input().split()))

def ia_to_s(a):
	return ' '.join([str(s) for s in a])

def solve(n, k):
	m = k // (n - 1)
	return m * n - 1 if k == m * (n - 1) else m * n + (k - m * (n - 1))

def main():
	for _ in range(ri()):
		(n, k) = ria()
		print(solve(n, k))
main()


import math

def div(n, k):
	return math.ceil(k / (n - 1)) + k - 1
t = int(input())
for i in range(t):
	string = input()
	I = string.split()
	n = int(I[0])
	k = int(I[1])
	print(div(n, k))


t = int(input())
arr = []
for i in range(t):
	(n, k) = map(int, input().split())
	if k < n:
		arr.append(k)
	else:
		position = n - 1
		count = n - 1
		nums = 1
		if k // count == k / count:
			position += n * (k // count - 1)
			count += (n - 1) * (k // count - 1)
		else:
			position += n * (k // count)
			count += (n - 1) * (k // count)
		if count == k:
			arr.append(position)
		elif count > k:
			position -= count - k
			arr.append(position)
for x in arr:
	print(x)


t = int(input())
for _ in range(t):
	(n, k) = map(int, input().split())
	l = 0
	r = 2 * k
	while l < r:
		m = (l + r) // 2
		if m - m // n >= k:
			r = m
		else:
			l = m + 1
	print(r)


from math import floor
t = int(input())
for i in range(t):
	inpt = input().split()
	n = int(inpt[0])
	k = int(inpt[1])
	step1 = n * k
	if step1 % (n - 1) > 0:
		print(int(floor(step1 / (n - 1))))
	else:
		print(int(step1 / (n - 1) - 1))


t = int(input())
for _ in range(t):
	(n, k) = map(int, input().split())
	d = n - 1
	d2 = k // d
	if k % d == 0:
		d2 -= 1
	print(k + d2)


t = int(input(''))
for i in range(t):
	s = input('')
	L = s.split(' ')
	(n, k) = (int(L[0]), int(L[1]))
	if k < n:
		print(k)
	elif n == 2:
		print(2 * k - 1)
	elif k % (n - 1) != 0:
		res = n * (k // (n - 1)) + k % (n - 1)
		print(res)
	else:
		res = n * (k // (n - 1)) - 1
		print(res)


from math import *
from bisect import bisect_left, bisect_right
from queue import Queue
from sys import stdin, stdout
from collections import Counter
input = lambda : stdin.readline().strip()
fast_print = stdout.write
t = int(input())
for _ in range(t):
	(n, k) = map(int, input().split())
	if k % (n - 1) == 0:
		fast_print(str(n * (k // (n - 1)) + k % (n - 1) - 1) + '\n')
	else:
		fast_print(str(n * (k // (n - 1)) + k % (n - 1)) + '\n')


from sys import stdin, stdout
for test in range(int(stdin.readline())):
	arr = [int(x) for x in stdin.readline().split()]
	n = arr[0]
	k = arr[1]
	if k < n:
		print(k)
	elif n == k:
		print(n + 1)
	else:
		num = k // (n - 1)
		if k % (n - 1) == 0:
			print(n * num - 1)
		else:
			print(n * num + k % (n - 1))


def int_in():
	return int(input())

def map_in():
	return map(int, input().split())
t = int_in()
for _ in range(t):
	(n, k) = map_in()
	p = k // (n - 1) * n
	if k % (n - 1) == 0:
		print(p - 1)
	else:
		print(p + k % (n - 1))


n = int(input())
for x in range(n):
	(t, q) = list(map(int, input().split()))
	low = 0
	high = 10 ** 11
	aq = True
	while low <= high:
		mid = (low + high) // 2
		if mid - mid // t == q:
			count = mid
			xl = mid - 1
			while True:
				if xl - xl // t == q:
					xl -= 1
					count -= 1
				else:
					print(count)
					aq = False
					break
		if not aq:
			break
		elif mid - mid // t > q:
			high = mid
		else:
			low = mid


t = int(input())

def result(n, k):
	if k % (n - 1) == 0:
		return n * (k // (n - 1)) - 1
	else:
		return n * (k // (n - 1)) + k % (n - 1)
for i in range(t):
	(n, k) = input().split()
	n = int(n)
	k = int(k)
	print(result(n, k))


import math
t = int(input())
while t:
	(num, k) = map(int, input().split())
	tom = math.ceil(k / (num - 1))
	c = tom * (num - 1)
	p = num * tom
	ans = p - 1 - (c - k)
	print(ans)
	t -= 1


import sys
import math

def inputnum():
	return int(input())

def inputnums():
	return map(int, input().split())

def inputlist():
	return list(map(int, input().split()))

def inputstring():
	return [x for x in input()]
t = int(input())
for q in range(t):
	(n, k) = inputnums()
	print(k + (k - 1) // (n - 1))


import sys

def eprint(*args):
	print(*args, file=sys.stderr)
zz = 1
from math import *
if zz:
	input = sys.stdin.readline
else:
	sys.stdin = open('input.txt', 'r')
	sys.stdout = open('all.txt', 'w')
t = int(input())
while t > 0:
	t -= 1
	(n, k) = map(int, input().split())
	p = k // (n - 1)
	if k % (n - 1) == 0:
		print((p - 1) * n + n - 1)
	else:
		print(p * n + k % (n - 1))


t = int(input())
for i in range(t):
	(n, k) = map(int, input().split())
	s = (k - 1) // (n - 1)
	n1 = n * s
	g = n1 - s
	l = k - g
	print(n1 + l)


for _ in range(int(input())):
	(n, k) = map(int, input().split())
	b = n - 1
	cc = k // b
	rem = k % b
	if rem == 0:
		ans = n * cc - 1
	else:
		ans = n * cc + rem
	print(ans)


from math import ceil
t = int(input())
while t:
	(n, k) = map(int, input().split())
	print(k + (k - 1) // (n - 1))
	t -= 1


t = 1
t = int(input())

def solve():
	(n, k) = map(int, input().split())
	if k % (n - 1) == 0:
		tr = k // (n - 1) * n - 1
	else:
		tr = k // (n - 1) * n + k % (n - 1)
	print(tr)
for xx in range(t):
	solve()


import math
t = int(input())
while t:
	t = t - 1
	(m, n) = map(int, input().split())
	a = n // m + n % m
	pre = n
	count = 0
	count += n // m
	while a >= m:
		n = a
		a = n // m + n % m
		count += n // m
	print(count + pre)


b = 'abcdefghijklmnopqrstuvwxyz'
arr = []
d = []
count = 0
t = int(input())
for i in range(t):
	(n, k) = map(int, input().split())
	if n > k:
		print(k)
		continue
	if n == k:
		print(k + 1)
		continue
	if k % (n - 1) == 0:
		print(k // (n - 1) * n - 1)
	else:
		print(n * (k // (n - 1)) + (k - (n - 1) * (k // (n - 1))))


tc = int(input())
for t in range(tc):
	arr = input().split()
	n = int(arr[0])
	k = int(arr[1])
	print(int(k + (k - 1) / (n - 1)))


t = int(input())
for _ in range(t):
	(n, k) = map(int, input().split())
	aa = []
	if k < n:
		print(k)
	else:
		xd = k - (n - 1)
		tp = xd % (n - 1)
		nn = xd // (n - 1)
		if tp == 0:
			tpp = n + (nn - 1) + nn * (n - 1)
			print(tpp)
		else:
			tpp = n + (nn - 1) + nn * (n - 1) + 1
			print(tpp + tp)


kol = int(input())
G = 0
start = 0
rez = []
for i in range(0, kol):
	start = 0
	(n, k) = map(int, input().split())
	G = k // (n - 1)
	if G > 0:
		start = G * n
		if k % (n - 1) == 0:
			start -= 1
	start += k % (n - 1)
	rez.append(start)
for j in rez:
	print(j)


def sol():
	(x, y) = map(int, input().split())
	p = y // (x - 1)
	if y % (x - 1) == 0:
		p -= 1
	print(p + y)
for n in range(int(input())):
	sol()


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


t = int(input())
for test in range(t):
	(n, k) = map(int, input().split())
	c = k % (n - 1)
	c2 = n * (k // (n - 1))
	if c == 0:
		c2 -= 1
	print(c + c2)


import sys, random
from bisect import bisect_left, bisect_right
input = sys.stdin.readline

def main():
	inf = 10 ** 20
	t = int(input())
	for _ in range(1, t + 1):
		(n, k) = map(int, input().split())
		k -= 1
		print(k % (n - 1) + 1 + n * (k // (n - 1)))
main()


import sys
data = [line.strip() for line in sys.stdin]
for line in data[1:]:
	(n, k) = line.split()
	n = int(n)
	k = int(k)
	if n > k:
		print(k)
	elif n == k:
		print(k + 1)
	else:
		shift = k // n
		while True:
			new_k = k + shift
			if new_k // n > shift:
				shift = new_k // n
			else:
				break
		print(k + shift)


def count(x, p):
	return x - x // p
t = eval(input())
while t:
	t -= 1
	(n, k) = eval(','.join(input().split()))
	(l, r, ans) = (1, int(10000000000000.0), 0)
	while l <= r:
		mid = l + r >> 1
		if count(mid, n) >= k:
			ans = mid
			r = mid - 1
		else:
			l = mid + 1
	print(ans)


t = int(input())
for _ in range(t):
	(n, k) = [int(x) for x in input().split()]
	if n == k:
		print(n + 1)
	else:
		div = k // (n - 1)
		rem = k % (n - 1)
		if rem == 0:
			print(div * n - 1)
		else:
			print(div * n + rem)


from math import *
mod = 10 ** 9 + 7

def _in():
	return [int(x) for x in input().split(' ')]

def main():
	(n, k) = _in()
	fac = k // (n - 1)
	rem = k % (n - 1)
	if rem == 0:
		ans = fac * n - 1
	else:
		ans = fac * n + rem
	print(ans)
for _ in range(int(input())):
	main()


import math

def func(B, A):
	a = math.ceil(A / (B - 1)) - 1
	b = A % (B - 1)
	if b == 0:
		b = B - 1
	return a * B + b
x = int(input())
a = []
for _ in range(x):
	a.append(list(map(int, input().split())))
for i in a:
	ans = func(i[0], i[1])
	print(ans)


test = int(input())
for _ in range(test):
	(n, k) = map(int, input().split())
	d = k // n
	k += d
	d1 = d
	while k // n - d != 0:
		d1 = d
		d = k // n
		k += k // n - d1
	if k % n == 0:
		print(k + 1)
	else:
		print(k)


n = int(input())
for i in range(n):
	(a, b) = input().split()
	(a, b) = (int(a), int(b))
	x = a - 1
	y = b // x
	z = b % x
	r = y * a + z
	if z == 0:
		r -= 1
	print(r)


for i in range(int(input())):
	(n, k) = map(int, input().split())
	if n == k:
		print(n + 1)
	elif k < n:
		print(k)
	elif n < 100000:
		l = []
		for j in range(1, n):
			l.append(j)
		a = len(l)
		if a >= k:
			print(l[k - 1])
		else:
			b = k % a
			e = k - a
			if e % a != 0:
				c = e // a + 1
			else:
				c = e // a
			d = l[b - 1] + n * c
			print(d)
	else:
		a = k // n
		p = 0
		y = k + a
		for j in range(k, y + 1):
			if j % n == 0:
				p = p + 1
		print(y + p)


t = int(input())
for i in range(t):
	(n, k) = map(int, input().split())
	(zm, zd) = (k % (n - 1), k // (n - 1))
	check = 0
	if zm != 0 and check == 0:
		print(zd * n + zm)
	elif check == 0:
		print(zd * n - 1)
	else:
		print(-1)


import sys
t = int(input())
for _ in range(t):
	(n, k) = map(int, input().split())
	cnt = int(k / (n - 1))
	ans = cnt * n + k % (n - 1)
	if k % (n - 1) == 0:
		ans -= 1
	print(ans)


class SegmentTree:

	def __init__(self, data, default=0, func=lambda a, b: a + b):
		self._default = default
		self._func = func
		self._len = len(data)
		self._size = _size = 1 << (self._len - 1).bit_length()
		self.data = [default] * (2 * _size)
		self.data[_size:_size + self._len] = data
		for i in reversed(range(_size)):
			self.data[i] = func(self.data[i + i], self.data[i + i + 1])

	def __delitem__(self, idx):
		self[idx] = self._default

	def __getitem__(self, idx):
		return self.data[idx + self._size]

	def __setitem__(self, idx, value):
		idx += self._size
		self.data[idx] = value
		idx >>= 1
		while idx:
			self.data[idx] = self._func(self.data[2 * idx], self.data[2 * idx + 1])
			idx >>= 1

	def __len__(self):
		return self._len

	def query(self, start, stop):
		if start == stop:
			return self.__getitem__(start)
		stop += 1
		start += self._size
		stop += self._size
		res = self._default
		while start < stop:
			if start & 1:
				res = self._func(res, self.data[start])
				start += 1
			if stop & 1:
				stop -= 1
				res = self._func(res, self.data[stop])
			start >>= 1
			stop >>= 1
		return res

	def __repr__(self):
		return 'SegmentTree({0})'.format(self.data)
import os
import sys
from io import BytesIO, IOBase
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
input = lambda : sys.stdin.readline().rstrip('\r\n')
from bisect import bisect_right, bisect_left
from fractions import Fraction

def pre(s):
	n = len(s)
	pi = [0] * n
	for i in range(1, n):
		j = pi[i - 1]
		while j and s[i] != s[j]:
			j = pi[j - 1]
		if s[i] == s[j]:
			j += 1
		pi[i] = j
	return pi

def prod(a):
	ans = 1
	for each in a:
		ans = ans * each
	return ans

def pari(a):
	for i in range(0, 2, n):
		print(i)
	for i in range(1, 2, n):
		print(i)
from math import gcd

def lcm(a, b):
	return a * b // gcd(a, b)

def f(n, a=1):
	if a == 1:
		a = []
	s = len(str(n))
	p = 10 ** (s - 1)
	ans = 1
	a += [n // p * p]
	n -= a[0]
	if n:
		ans += 1
		a += f(n)
		return a
	else:
		return a
for _ in range(int(input())):
	(n, k) = map(int, input().split())
	div = k // (n - 1)
	rem = k % (n - 1)
	if rem == 0:
		rem -= 1
	print(n * div + rem)


for _ in range(int(input())):
	(n, k) = map(int, input().split())
	block = k // (n - 1)
	num = k % (n - 1)
	res = block * n + num
	if num:
		print(res)
	else:
		print(block * n - 1)


def solve():
	(n, k) = map(int, input().split())
	r = k // (n - 1)
	ind = r * n
	if k % (n - 1) > 0:
		print(ind + k % (n - 1))
	else:
		print(ind - 1)
tests = int(input())
while tests:
	tests -= 1
	solve()


import math

def solve(n, k):
	result = math.floor((k - 1) / (n - 1)) + k
	print(result)
t = int(input().strip())
for _ in range(t):
	nk = input().split()
	n = int(nk[0])
	k = int(nk[1])
	solve(n, k)


def r_func(n, k):
	if k < n:
		print(k)
	elif k == n:
		print(k + 1)
	else:
		rem = k % (n - 1)
		if rem == 0:
			rem = -1
		div = k // (n - 1)
		print(n * div + rem)
num = int(input())
for i in range(num):
	(n, k) = [int(x) for x in input().split()]
	r_func(n, k)


for k in range(int(input())):
	(a, b) = map(int, input().split())
	l = -1
	r = int(100000000000.0)
	while l + 1 != r:
		mid = (r + l) // 2
		if mid < b + mid // a:
			l = mid
		else:
			r = mid
	print(r)


from operator import ior
from functools import reduce
for _ in range(int(input())):
	(n, k) = list(map(int, input().split()))
	li = []
	ans = 0
	if k % (n - 1) == 0:
		ans = k // (n - 1) - 1
	else:
		ans = k // (n - 1)
	print(ans + k)


import math, sys
from sys import stdin, stdout
from collections import Counter, defaultdict, deque
input = stdin.readline
I = lambda : int(input())
li = lambda : list(map(int, input().split()))

def case():
	(n, k) = li()
	need = (k - 1) // (n - 1)
	print(k + need)
for _ in range(int(input())):
	case()


def solution(n, k):
	mult = k // (n - 1)
	rem = k % (n - 1)
	if rem:
		print(n * mult + rem)
	else:
		print(n * mult - 1)
for i in range(int(input())):
	(a, b) = map(int, input().split())
	solution(a, b)


for _ in range(int(input())):
	(a, b) = map(int, input().split())
	l = 1
	r = 2 * b
	while l < r:
		m = (l + r) // 2
		if m - m // a >= b:
			r = m
		else:
			l = m + 1
	print(l)


for _ in range(int(input())):
	(n, k) = map(int, input().split())
	n_ = k
	i = n_ - k // n
	while i != k:
		n_ += k - i
		i = n_ - n_ // n
	print(n_)


import math
a = int(input())
c = float(0)
for i in range(a):
	(n, k) = map(int, input().split())
	c = n * (k / (n - 1))
	c = math.ceil(c)
	c = c - 1
	print(c)
	c = 0


import sys
input = lambda : sys.stdin.readline().strip()
t = int(input())
while t:
	t -= 1
	(n, k) = map(int, input().split())
	if k == 1:
		print(1)
		continue
	lo = 1
	hi = 2 * 10 ** 9
	while lo < hi:
		mi = (lo + hi) // 2
		v = mi // n
		v = mi - v
		if v < k:
			lo = mi + 1
		else:
			hi = mi
	print(lo)


t = int(input())
while t:
	t -= 1
	(n, k) = input().split()
	n = int(n)
	k = int(k)
	if not k % (n - 1):
		print(k // (n - 1) * n - 1)
	else:
		l = int(k / (n - 1))
		print(l * n + k % (n - 1))


n = int(input())
for i in range(n):
	(num, count) = map(int, input().split())
	(p, rem) = (count // (num - 1), count % (num - 1))
	base = num * p
	if count % (num - 1) == 0:
		print(base - 1)
	else:
		print(base + rem)


numbers_count = int(input())
numbers = [input() for i in range(0, numbers_count)]
for number in numbers:
	(n, k) = (int(n) for n in number.split(' '))
	print(f'{k + (k - 1) // (n - 1)}')


for i in range(int(input())):
	(x, y) = [int(i) for i in input().split()]
	z = y
	a = 0
	while z >= x:
		a += z // x
		z = z // x + z % x
	if (y + a) % x >= x:
		a += 1
	print(y + a)


t = int(input())
output = list()
while t:
	(n, k) = list(map(int, input().split()))
	output.append((k * n - 1) // (n - 1))
	t -= 1
for i in output:
	print(i)


t = int(input())
while t:
	t -= 1
	(n, k) = map(int, input().split())
	r = n - 1
	x = k // r
	b = k % r
	ans = n * x + b
	if b == 0:
		ans -= 1
	print(ans)


from sys import stdin, stdout
testcase = int(input())
while testcase > 0:
	(n, k) = [int(x) for x in input().split()]
	if n == k:
		print(k + 1)
	elif n > k:
		print(k)
	else:
		result = 0
		r = k % (n - 1)
		q = k // (n - 1)
		if r == 0:
			result = n * q - 1
		else:
			result = n * q + r
		print(result)
	testcase -= 1


for _ in range(int(input())):
	(n, k) = map(int, input().split())
	count = 0
	if n > k:
		print(k)
		continue
	if n == k:
		print(n + 1)
		continue
	x = k // (n - 1)
	if k % (n - 1) == 0:
		print(n * x + k % (n - 1) - 1)
	else:
		print(n * x + k % (n - 1))


import getopt
import sys
import math
onlyCase = -1
verbose = False
try:
	(opts, args) = getopt.getopt(sys.argv[1:], 'vc:', ['case='])
except getopt.GetoptError as err:
	print(str(err))
	sys.exit(2)
for (o, a) in opts:
	if o in ('-c', '--case'):
		onlyCase = int(a)
	elif o == '-v':
		verbose = True
	else:
		sys.exit()
ncases = int(input())
for c in range(1, ncases + 1):
	(n, k) = [int(x) for x in input().split()]
	if onlyCase != -1 and onlyCase != c:
		continue
	r = math.ceil(k / (n - 1) * n - 1)
	print(r)


t = int(input())
for _ in range(t):
	l1 = input().split(' ')
	n = int(l1[0])
	k = int(l1[1])
	row = (k - 1) // (n - 1)
	start = n * row
	start += k - row * (n - 1)
	print(start)


for _ in range(int(input())):
	(n, k) = map(int, input().split())
	x = k // (n - 1)
	r = k % (n - 1)
	if r == 0:
		ans = n * x - 1
	else:
		ans = n * x + r
	print(ans)


import copy

def solve():
	(n, k) = map(int, input().split())
	if k % (n - 1) == 0:
		print(k // (n - 1) * n + k % (n - 1) - 1)
	else:
		print(k // (n - 1) * n + k % (n - 1))

def test():
	for i in range(int(input())):
		solve()
test()


import collections
from sys import stdin
input = stdin.readline

def main():
	test = int(input())
	for t in range(test):
		l = [int(i) for i in input().split(' ')]
		n = l[0]
		k = l[1]
		i = k % (n - 1)
		j = k // (n - 1)
		if k < n:
			print(k)
		elif k % (n - 1) != 0:
			print(n * j + i)
		else:
			print(n * j - 1)
main()


t = int(input())
l = []
for i in range(t):
	s = list(map(int, input().split()))
	l.append(s)
for j in l:
	num = j[1]
	num1 = j[1] // j[0]
	k = num - num1
	while k != j[1]:
		num = num // j[0] + j[1]
		k = num - num // j[0]
	print(num)


import math
t = int(input())
for i in range(t):
	(n, k) = map(int, input().split())
	j = k // (n - 1)
	w = n * j
	if w - j == k:
		print(w - 1)
	elif w - j < k:
		print(w + (k - (w - j)))
	else:
		print(w, 'xx')


t = int(input())
for i in range(t):
	(n, k) = [int(i) for i in input().split()]
	a = k // (n - 1) * n + k % (n - 1)
	print(a - (a % n == 0))


for _ in range(int(input())):
	(n, k) = map(int, input().split())
	needed = k // n
	s = a = k + needed
	while s // n != needed:
		s = s + (a // n - needed)
		needed = a // n
		a = s
	print(s)


t = int(input())
ans = []
for _ in range(t):
	(n, k) = map(int, input().split(' '))
	if n == k:
		ans.append(str(k + 1))
		continue
	elif k < n:
		ans.append(str(k))
		continue
	part = k // (n - 1)
	mod = k % (n - 1)
	if mod != 0:
		ans.append(part * n + k % (n - 1))
	else:
		ans.append(part * n - 1)
for num in ans:
	print(num)


t = int(input())
for _ in range(t):
	(n, k) = map(int, input().split())
	m = k // n
	r = k // n + k
	d = r // n
	while d != m:
		r += d - m
		m = d
		d = r // n
	print(r)


test_cases = int(input())
while test_cases > 0:
	(num, k) = map(int, input().split())
	cycle = num - 1
	numCycle = (k - 1) // cycle
	theNum = numCycle * num
	theNum += k - numCycle * cycle
	print(theNum)
	test_cases -= 1


import math
t = int(input())
for _ in range(t):
	(n, k) = map(int, input().split())
	temp = n * (math.ceil(k / (n - 1)) - 1)
	ans = temp + (k - (n - 1) * (math.ceil(k / (n - 1)) - 1))
	print(ans)


t = int(input())
out = ''
while t > 0:
	t -= 1
	(n, k) = [int(i) for i in input().split(' ')]
	out += str(k + (k - 1) // (n - 1)) + '\n'
print(out)


from math import floor

def main():
	for _ in range(int(input())):
		(n, k) = map(int, input().split())
		x = k // (n - 1)
		y = k % (n - 1)
		if y:
			print(n * x + y)
		else:
			print(n * x - 1)
main()


def solve():
	t = int(input())
	for i in range(t):
		(target, k) = list(map(int, input().split(' ')))
		if k < target:
			print(k)
			continue
		non_divisible = target - 1
		remainder = k % non_divisible
		if remainder == 0:
			print(target * (k // non_divisible) - 1)
		else:
			print(target * (k // non_divisible) + remainder)
solve()


test = int(input())
for tes in range(test):
	(n, k) = list(map(int, input().split()))
	start = k // (n - 1)
	full = n * start
	reach = full - start
	left = k - reach
	if k % (n - 1) != 0:
		print(full + left)
	else:
		print(full + left - 1)


import sys

def minp():
	return sys.stdin.readline().strip()

def mint():
	return int(minp())

def mints():
	return map(int, minp().split())

def solve():
	(n, k) = mints()
	x = k
	while k >= n:
		x += k // n
		k = k % n + k // n
	print(x)
for i in range(mint()):
	solve()


from sys import stdout, stdin

def main():
	for _ in range(int(stdin.readline())):
		(n, k) = map(int, stdin.readline().split())
		add1 = 1
		dNum = k // n
		newK = k + dNum
		while add1 > 0:
			dNum2 = newK // n
			add1 = dNum2 - dNum
			dNum = dNum2
			newK += add1
		print(newK)
main()


for _ in ' ' * int(input()):
	(n, k) = map(int, input().split())
	s1 = k - 1
	k += s1 // (n - 1)
	print(k)


import sys
input = sys.stdin.readline
for _ in range(int(input())):
	(n, k) = map(int, input().split())
	s = 1
	s1 = 0
	while s != s1:
		s1 = s
		s = int(s / n) + k
	print(s)


from collections import Counter
import itertools
from functools import lru_cache
import sys
import math

def helper():
	pass

def solve():
	(n, k) = map(int, input().split(' '))
	if k < n:
		print(k)
		return
	else:
		period = n - 1
		skips = math.ceil(k // period)
		if k % period != 0:
			skips = math.ceil(k // period) + 1
		targ = n * skips - 1
		delta = (n - 1) * skips - k
		print(targ - delta)
t = int(input())
for _ in range(t):
	solve()


t = int(input())
for _ in range(t):
	(n, k) = map(int, input().split())
	p = k
	x = 0
	while k >= n:
		x = k // n
		p += x
		k = x + k % n
	print(p)


tests_cases = int(input())
cont = 0
while cont < tests_cases:
	numbers = input().split(' ')
	n = int(numbers[0])
	k = int(numbers[1])
	num_x = k / (n - 1)
	temp_result = k + num_x
	if temp_result % n == 0:
		print(int(temp_result - 1))
	else:
		print(int(temp_result))
	cont = cont + 1


import math, string, itertools, fractions, heapq, collections, re, array, bisect, sys, copy, functools
sys.setrecursionlimit(10 ** 7)
inf = 10 ** 20
eps = 1.0 / 10 ** 10
mod = 10 ** 9 + 7
mod2 = 998244353
dd = [(-1, 0), (0, 1), (1, 0), (0, -1)]
ddn = [(-1, 0), (-1, 1), (0, 1), (1, 1), (1, 0), (1, -1), (0, -1), (-1, -1)]

def LI():
	return list(map(int, sys.stdin.readline().split()))

def LLI():
	return [list(map(int, l.split())) for l in sys.stdin.readlines()]

def LI_():
	return [int(x) - 1 for x in sys.stdin.readline().split()]

def LF():
	return [float(x) for x in sys.stdin.readline().split()]

def LS():
	return sys.stdin.readline().split()

def I():
	return int(sys.stdin.readline())

def F():
	return float(sys.stdin.readline())

def S():
	return input()

def pf(s):
	return print(s, flush=True)

def pe(s):
	return print(str(s), file=sys.stderr)

def JA(a, sep):
	return sep.join(map(str, a))

def JAA(a, s, t):
	return s.join((t.join(map(str, b)) for b in a))

def main():
	t = I()
	rr = []
	for _ in range(t):
		(n, k) = LI()
		t = (k - 1) // (n - 1)
		r = n * t + (k - 1) % (n - 1) + 1
		rr.append(r)
	return JA(rr, '\n')
print(main())


R1 = lambda : list(map(int, input().split()))
R2 = lambda : int(input())
for _ in range(R2()):
	(n, k) = R1()
	need = (k - 1) / (n - 1)
	print(k + int(need))


for testcase in range(int(input())):
	(n, k) = map(int, input().split())
	(q, r) = divmod(k, n - 1)
	print(n * q + r - (r == 0))


import sys
from functools import lru_cache, cmp_to_key
from heapq import merge, heapify, heappop, heappush
from math import ceil, floor, gcd, fabs, factorial, fmod, sqrt, inf
from collections import defaultdict as dd, deque, Counter as C
from itertools import combinations as comb, permutations as perm
from bisect import bisect_left as bl, bisect_right as br, bisect
from time import perf_counter
from fractions import Fraction
mod = pow(10, 9) + 7
mod2 = 998244353

def data():
	return sys.stdin.readline().strip()

def out(*var, end='\n'):
	sys.stdout.write(' '.join(map(str, var)) + end)

def l():
	return list(sp())

def sl():
	return list(ssp())

def sp():
	return map(int, data().split())

def ssp():
	return map(str, data().split())

def l1d(n, val=0):
	return [val for i in range(n)]

def l2d(n, m, val=0):
	return [l1d(n, val) for j in range(m)]
for _ in range(int(data())):
	(n, k) = sp()
	if n == k:
		out(n + 1)
		continue
	if n > k:
		out(k)
		continue
	answer = k // (n - 1) + int(k % (n - 1) != 0)
	out(answer + k - 1)


count = int(input())
for i in range(count):
	numbers = input().split(' ')
	n = int(numbers[0])
	k = int(numbers[1])
	ceil = k // (n - 1)
	ost = k % (n - 1)
	if ost == 0:
		res = ceil * n - 1
	else:
		res = ceil * n + ost
	print(res)


n = int(input())
for i in range(n):
	lis = list(map(int, input().split()))
	n1 = lis[0]
	n2 = lis[1]
	k1 = n1 - 1
	k2 = n2 // k1
	n3 = n2 % k1
	if n3 == 0:
		print(n1 * k2 + n3 - 1)
	else:
		print(n1 * k2 + n3)


test = int(input())
for i in range(test):
	(n, k) = input().split()
	k = int(k)
	n = int(n)
	m = n - 1
	p = k - 1
	rem = p % m
	quo = p // m
	ans = n * quo + rem + 1
	print(ans)


from math import *
a = int(input())
for _ in range(a):
	(b, c) = map(int, input().split())
	d = b - 1
	e = ceil(c / d)
	f = d * (e - 1)
	print(b * (e - 1) + (c - f))


def non_divide(n, k):
	steps = k // (n - 1)
	add = k % (n - 1)
	if add != 0:
		ans = steps * n + add
		print(ans)
	else:
		print(steps * n - 1)
t = int(input())
for i in range(t):
	(n, k) = list(map(int, input().split()))
	non_divide(n, k)


import math

def main():
	for _ in range(int(input())):
		(n, k) = map(int, input().split())
		print(k + math.floor((k - 1) / (n - 1)))
main()


from __future__ import division, print_function
from fractions import Fraction
import sys
import os
from io import BytesIO, IOBase
from itertools import *
import bisect
from heapq import *
from math import *
from copy import *
from collections import deque
from collections import Counter as counter
from itertools import combinations as comb
from itertools import permutations as permutate
from bisect import bisect_left as bl
from bisect import bisect_right as br
from bisect import bisect
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')

def print(*args, **kwargs):
	(sep, file) = (kwargs.pop('sep', ' '), kwargs.pop('file', sys.stdout))
	at_start = True
	for x in args:
		if not at_start:
			file.write(sep)
		file.write(str(x))
		at_start = False
	file.write(kwargs.pop('end', '\n'))
	if kwargs.pop('flush', False):
		file.flush()
if sys.version_info[0] < 3:
	(sys.stdin, sys.stdout) = (FastIO(sys.stdin), FastIO(sys.stdout))
else:
	(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
from types import GeneratorType

def iterative(f, stack=[]):

	def wrapped_func(*args, **kwargs):
		if stack:
			return f(*args, **kwargs)
		to = f(*args, **kwargs)
		while True:
			if type(to) is GeneratorType:
				stack.append(to)
				to = next(to)
				continue
			stack.pop()
			if not stack:
				break
			to = stack[-1].send(to)
		return to
	return wrapped_func
mod = 1000000007

def inp():
	return sys.stdin.readline().rstrip('\r\n')

def out(var):
	sys.stdout.write(str(var))

def lis():
	return list(map(int, inp().split()))

def stringlis():
	return list(map(str, inp().split()))

def sep():
	return map(int, inp().split())

def strsep():
	return map(str, inp().split())

def zerolist(n):
	return [0] * n

def nextline():
	out('\n')

def testcase(t):
	for p in range(t):
		solve()

def printlist(a):
	for p in range(0, len(a)):
		out(str(a[p]) + ' ')

def lcm(a, b):
	return a * b // gcd(a, b)

def power(a, b):
	ans = 1
	while b > 0:
		if b % 2 == 1:
			ans *= a
		a *= a
		b //= 2
	return ans

def ncr(n, r):
	return factorial(n) // (factorial(r) * factorial(max(n - r, 1)))

def isPrime(n):
	if n <= 1:
		return False
	if n <= 3:
		return True
	if n % 2 == 0 or n % 3 == 0:
		return False
	i = 5
	while i * i <= n:
		if n % i == 0 or n % (i + 2) == 0:
			return False
		i = i + 6
	return True

def solve():
	(n, k) = sep()
	ans = k // (n - 1) * n + k % (n - 1)
	if k % (n - 1) == 0:
		print(ans - 1)
	else:
		print(ans)
testcase(int(inp()))


import sys, bisect
from math import gcd
input = sys.stdin.readline

def inp():
	return int(input().rstrip())

def inlt():
	return list(map(int, input().rstrip().split()))

def insr():
	s = input().rstrip()
	return s[:len(s) - 1]

def invr():
	return map(int, input().rstrip().split())
t = inp()
for _ in range(t):
	(n, k) = invr()
	num = n - 1
	if num >= k:
		print(k)
	else:
		gaps = k // num + (1 if k % num != 0 else 0)
		bor = (gaps - 1) * n
		add = k - (gaps - 1) * num
		print(bor + add)


q = int(input())
while q:
	(n, k) = list(map(int, input().split()))
	a = int(k / (n - 1))
	b = int(k % (n - 1))
	if b:
		o = n * a + b
	else:
		o = n * a - 1
	q -= 1
	print(o)


from math import *
for _ in range(int(input())):
	(n, k) = map(int, input().split())
	x = ceil(k / (n - 1))
	tmp = k + x - 1
	print(tmp)


def solve(n, k):
	coeff = k // (n - 1)
	rem = k % (n - 1)
	ans = n * coeff
	if rem:
		ans += rem
	else:
		ans -= 1
	return ans

def main():
	tests = int(input())
	while tests:
		n_k = input().split()
		print(solve(int(n_k[0]), int(n_k[1])))
		tests -= 1
main()


from sys import stdin, stdout
from math import gcd, ceil, sqrt
ii1 = lambda : int(stdin.readline().strip())
is1 = lambda : stdin.readline().strip()
iia = lambda : list(map(int, stdin.readline().strip().split()))
isa = lambda : stdin.readline().strip().split()
mod = 1000000007
tc = ii1()
for _ in range(tc):
	(n, k) = iia()
	lower = k // n
	extra = lower + (k - lower * n)
	num = n * lower
	while extra != 0:
		if num / n != (num + extra) / n:
			temp = extra
			extra = (num + extra) // n - num // n
			num += temp
	print(num)


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


import math
t = int(input())
for i in range(t):
	(n, k) = map(int, input().split())
	x = math.floor((k - 1) / (n - 1))
	s = x * n
	r = s - x
	print(s + (k - r))


from math import ceil as p
n = int(input())
for _ in range(n):
	(a, b) = map(int, input().split())
	c = a - 1
	q = p(b / c)
	z = q * c
	m = a * q
	z = z + 1
	w = z - b
	m = m - w
	print(m)


t = int(input())
while t > 0:
	(n, k) = [int(x) for x in input().strip().split(' ')]
	need = int((k - 1) // (n - 1))
	print(k + need)
	t = t - 1


def findNum(n, k):
	if n > k:
		print(str(k))
	elif n == k:
		print(str(k + 1))
	elif n < k:
		num = k // n
		i = num * n
		valNeeded = num + k - n * num
		k = valNeeded
		while valNeeded >= n:
			num = k // n
			i += num * n
			valNeeded = num + k - n * num
			k = valNeeded
		if valNeeded > 0:
			i += valNeeded
		print(i)
for _ in range(int(input())):
	(n, k) = list(map(int, input().split()))
	findNum(n, k)


def main():
	t = int(input())
	for i in range(t):
		(n, k) = map(int, input().split())
		if n > k:
			print(k)
		else:
			print(k + (k - 1) // (n - 1))
main()


def countdivisible(n, divisor):
	return n // divisor

def run():
	(n, k) = list(map(int, input().split()))
	curr = max(k, (k - 1) * n // (n - 1))
	while True:
		if curr - countdivisible(curr, n) == k:
			print(curr)
			break
		curr += 1
T = int(input())
for i in range(T):
	run()


for t in range(int(input())):
	(n, k) = map(int, input().split())
	(ub, lb) = (2 * 10 ** 9 + 1, 0)
	while ub >= lb:
		ans = (ub + lb) // 2
		c = ans // n * (n - 1) + ans % n
		if c > k:
			ub = ans - 1
		elif c < k:
			lb = ans + 1
		elif ans % n == 0:
			print(ans - 1)
			break
		else:
			print(ans)
			break


t = int(input())
for _ in range(t):
	(n, k) = map(int, input().split())
	temp = k // (n - 1)
	if temp * (n - 1) == k:
		print(n * temp - 1)
	else:
		print(n * temp + (k - temp * (n - 1)))


from collections import Counter, defaultdict, deque
from operator import itemgetter
import math
import sys
input = sys.stdin.readline

def solve():
	(n, k) = [int(x) for x in input().split()]
	res = k * n // (n - 1)
	if not res % n == 0:
		print(res)
	else:
		print(res - 1)
tt = int(input())
for test in range(tt):
	solve()


T = int(input())
while T > 0:
	(n, k) = map(int, input().split())
	b = k // (n - 1) * n
	a = k % (n - 1)
	if k % (n - 1) == 0:
		print(a + b - 1)
	elif n > k:
		print(k)
	else:
		print(a + b)
	T -= 1


from collections import defaultdict as dc
from heapq import *
import math
from bisect import bisect_left, bisect
import sys
from collections import deque as dq
from heapq import heapify, heappush, heappop
mod = 10 ** 9 + 7

def sinp():
	p = str(input())
	return p

def inp():
	p = int(input())
	return p

def line():
	p = list(map(int, input().split()))
	return p

def read_mat():
	n = inp()
	a = []
	for i in range(n):
		a.append(line())
	return a

def digit(n):
	s = str(n)
	p = 0
	for i in s:
		p += int(i) ** 2
	return p

def check(p, i, j):
	z = i + (j - i) // 2
	if p[z] - p[i] == p[j] - p[z]:
		return j - i
	return 0

def solve(a, b):
	ans = b
	if b % (a - 1) == 0:
		ans = ans + b // (a - 1) - 1
	else:
		ans = ans + b // (a - 1)
	return ans
for test in range(inp()):
	(a, b) = line()
	l = solve(a, b)
	print(l)


t = int(input())
for i in range(t):
	[n, k] = [int(c) for c in input().split()]
	y = k % (n - 1)
	x = (k - y) / (n - 1)
	if y == 0:
		print(int(x * n - 1))
	else:
		print(int(x * n + y))


t = int(input())
while t > 0:
	(n, k) = map(int, input().split())
	n1 = n
	sum1 = k
	while k >= n:
		k1 = k // n
		k = k % n + k1
		sum1 += k1
	print(sum1)
	t -= 1


n = int(input())
while n > 0:
	n = n - 1
	(x, k) = map(int, input().split())
	m = 0
	b = 0
	while 1:
		k = k + m
		f = int(k / x)
		m = f - b
		if m == 0:
			break
		k = k + m
		b = int(k / x)
		m = b - f
		if m == 0:
			break
	print(k)


t = int(input())
while t != 0:
	(n, k) = map(int, input().strip().split())
	x = n * k // (n - 1)
	if x % n == 0:
		x -= 1
	print(x)
	t -= 1


t = int(input())
aa = []
while t != 0:
	(m, n) = map(int, input().split())
	ss = int((n - 1) / (m - 1))
	aa.append(n + ss)
	t -= 1
for x in range(len(aa)):
	print(aa[x])


for i in range(int(input())):
	(n, k) = list(map(int, input().split()))
	if n > k:
		print(k)
	elif k == n:
		print(n + 1)
	else:
		print((k * n - 1) // (n - 1))


from math import ceil as c
t = int(input())
for _ in range(t):
	(n, k) = map(int, input().split())
	l = c(k / (n - 1)) - 1
	print(l + k)


for _ in range(int(input())):
	(n, k) = map(int, input().split())
	low = 0
	high = 1000000000000000000
	ans = -1
	while low <= high:
		mid = low + (high - low) // 2
		rc = mid - mid // n
		if rc >= k:
			ans = mid
			high = mid - 1
		else:
			low = mid + 1
	assert ans != -1
	print(ans)


from math import ceil
queries = int(input())
for _ in range(queries):
	(n, k) = map(int, input().split())
	current = k / n
	result = current
	while current >= 1:
		current /= n
		result += current
	print(int(k + result))


import sys
input = sys.stdin.readline
t = int(input())
for ti in range(1, t + 1):
	(n, k) = map(int, input().split())
	res = 0
	if k < n:
		res = k
	else:
		res = (k - 1) // (n - 1) * n
		k -= (k - 1) // (n - 1) * (n - 1)
		res += k
	print(res)


t = int(input())
for i in range(t):
	(n, k) = map(int, input().split(' '))
	p = k // (n - 1)
	q = k % (n - 1)
	if q > 0:
		ans = p * n + q
	else:
		ans = p * n - 1
	print(ans)


Test = int(input())
for t in range(Test):
	(N, K) = list(map(int, input().split()))
	Aux = int((K - 1) / (N - 1))
	print(Aux + K)


t = int(input())
for i1 in range(t):
	(n, k) = map(int, input().split())
	if k < n:
		print(k)
	if k == n:
		print(n + 1)
	if k > n:
		t1 = k // (n - 1)
		t2 = k % (n - 1)
		if t2 != 0:
			print(t1 * n + t2)
		else:
			print(t1 * n - 1)


def Kth(N, K):
	Result = 0
	Power = K // (N - 1)
	Remainder = K % (N - 1)
	if Remainder == 0:
		Remainder = -1
	Result = Remainder + Power * N
	return Result
T = int(input())
for i in range(T):
	L = list(map(int, input().split()))
	print(Kth(L[0], L[1]))


t = int(input())
for i in range(t):
	inp = input().split(' ')
	n = int(inp[0])
	k = int(inp[1])
	minimblocks = int(k) // int(n - 1)
	lef = int(k % (n - 1))
	ans = minimblocks * n
	if lef == 0:
		ans -= 1
	else:
		ans += lef
	print(ans)


from sys import stdin, stdout
from math import ceil
for case in range(int(stdin.readline())):
	(n, k) = [int(x) for x in stdin.readline().split()]
	if n > k:
		print(k)
		continue
	add = 0
	while add != (add + k) // n:
		add = (add + k) // n
	print(add + k)


for _ in range(int(input())):
	(n, k) = map(int, input().split())
	d = k % (n - 1)
	e = k // (n - 1)
	if d != 0:
		ans = e * n + d
	else:
		ans = e * n - 1
	print(ans)


for _ in range(int(input())):
	(n, k) = map(int, input().split())
	rem = int(k / (n - 1))
	tonum = n * rem
	reached = (n - 1) * rem
	find = k - reached
	if find == 0:
		find = -1
	print(tonum + find)


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


import sys
from bisect import *
from math import floor, sqrt, ceil, factorial as F, gcd, pi
from itertools import chain, combinations, permutations, accumulate
from collections import Counter, defaultdict, OrderedDict, deque
from array import array
INT_MAX = sys.maxsize
INT_MIN = -sys.maxsize - 1
mod = 1000000007
ch = 'abcdefghijklmnopqrstuvwxyz'
lcm = lambda a, b: a * b // gcd(a, b)
setbit = lambda x: bin(x)[2:].count('1')
Int = lambda type: type(sys.stdin.readline()) if type in [int, float] else type(sys.stdin.readline()).replace('\n', '')
Array = lambda type: list(map(type, sys.stdin.readline().split()))
Nums = lambda type: map(type, sys.stdin.readline().split())

def solve():
	T = Int(int)
	for _ in range(T):
		(n, k) = Nums(int)
		print(k + (k - 1) // (n - 1))
try:
	sys.stdin = open('input.txt', 'r')
except:
	pass
solve()


import heapq

def solve():
	(n, k) = map(int, input().split())
	left = 0
	right = k * n
	while left <= right:
		mid = (left + right) // 2
		if mid % n == 0:
			mid += 1
		nth = mid - mid // n
		if nth == k:
			print(mid)
			return
		if nth > k:
			right = mid
		if nth < k:
			left = mid
t = int(input())
for _ in range(t):
	solve()


num = int(input())
for i in range(num):
	(n, k) = map(int, input().split())
	i = k / (n - 1)
	if i == int(i):
		i -= 1
	else:
		i = int(i)
	res = k + i
	print(int(res))


import math

def find_k_indivisible_by_n(n, k):
	bucket = math.ceil(k / (n - 1))
	passed = (bucket - 1) * (n - 1)
	previous_divisible = (bucket - 1) * n
	return previous_divisible + (k - passed)
results = []
for _ in range(int(input())):
	results.append(str(find_k_indivisible_by_n(*[int(s) for s in input().split()])))
print('\n'.join(results), sep='')


for _ in range(int(input())):
	(n, k) = [int(x) for x in input().split()]
	p = n - 1
	ss = n * (k // p) + k % p
	if ss % n == 0:
		print(ss - 1)
	else:
		print(ss)


from sys import stdin, stdout
from math import gcd, sqrt, factorial, pi, inf
from collections import deque, defaultdict
from bisect import bisect, bisect_left
from time import time
from itertools import permutations as per
input = stdin.readline
R = lambda : map(int, input().split())
I = lambda : int(input())
S = lambda : input().rstrip('\r\n')
L = lambda : list(R())
P = lambda x: stdout.write(str(x) + '\n')
lcm = lambda x, y: x * y // gcd(x, y)
nCr = lambda x, y: f[x] * inv(f[y] * f[x - y] % N) % N
inv = lambda x: pow(x, N - 2, N)
sm = lambda x: (x ** 2 + x) // 2
N = 10 ** 9 + 7
for _ in range(I()):
	(n, k) = R()
	print(n * ((k + n - 2) // (n - 1)) - 1 - (n - 1 - k % (n - 1)) % (n - 1))


import math
testy = int(input(''))
results = []

def ktaliczba(n, k):
	mnoznik = math.floor((k - 1) / (n - 1))
	return mnoznik * n + k - mnoznik * (n - 1)
for i in range(0, testy):
	wejscie = input('')
	n = int(wejscie.split()[0])
	k = int(wejscie.split()[1])
	results.append(ktaliczba(n, k))
for result in results:
	print(result)


t = int(input())
for q in range(t):
	(n, k) = map(int, input().split())
	if n > k:
		print(k)
	else:
		qu = k // (n - 1)
		re = k % (n - 1)
		if re == 0:
			print(n * qu - 1)
		else:
			print(n * qu + re)


import math
t = int(input())
for i in range(t):
	(n, k) = map(int, input().split())
	rounding = math.floor((k - 1) / (n - 1))
	S = (k - 1) % (n - 1) + 1
	print(rounding * n + S)


t = int(input())
for z in range(t):
	(n, k) = map(int, input().split())
	a1 = k
	a2 = 0
	ans = k
	while a1 + a2 >= n:
		a1 = a1 + a2
		a2 = a1 % n
		a1 = a1 // n
		ans += a1
	print(ans)


import collections, heapq, itertools, math
groupby = itertools.groupby
rs = lambda : input()
ri = lambda : int(input())
rm = lambda : map(int, input().split())
rai = lambda : [int(x) for x in input().split()]

def solve(n, k):
	q = k // (n - 1)
	r = k - q * (n - 1)
	if r == 0:
		q -= 1
		r += n - 1
	return n * q + r
for t in range(ri()):
	(n, k) = rm()
	print(solve(n, k))


def handle(n, k):
	a = n - 1
	(x, r) = divmod(k, a)
	return x * n + (r if r > 0 else -1)
cases = int(input())
for case in range(cases):
	(n, k) = map(int, input().split())
	result = handle(n, k)
	print(result)


import sys
from math import sqrt, gcd, ceil, log
from bisect import bisect
from collections import defaultdict, Counter
from heapq import heapify, heappush, heappop
inp = sys.stdin.readline
read = lambda : list(map(int, inp().strip().split()))

def solve():
	ans = ''
	for _ in range(int(input())):
		(n, k) = read()
		s = k
		while k // n:
			s += k // n
			k = k // n + k % n
		if s % n == 0:
			s += 1
		ans += str(s) + '\n'
	print(ans)
solve()


def a(n, k):
	step = n - 1
	num = k / step
	a = k % step
	if num % 1 == 0:
		print(n * int(num) - 1)
	else:
		print(n * int(num) + a)

def inp():
	return list(map(int, input().split(' ')))
b = int(input())
d = []
for i in range(b):
	d.append(inp())
for i in d:
	a(i[0], i[1])


from collections import Counter
from collections import defaultdict
import math
import sys
input = sys.stdin.readline
rs = lambda : input().strip()
ri = lambda : int(input())
rl = lambda : list(map(int, input().split()))
rls = lambda : list(map(str, input().split()))
from collections import deque
t = int(input())
for _ in range(0, t):
	(n, k) = rl()
	n1 = n - 1
	s1 = math.ceil(k / n1) - 1
	s2 = n * s1
	ans = s2 + (k - n1 * s1)
	print(ans)


t = int(input())
for _ in range(t):
	s = input().split()
	n = int(s[0])
	k = int(s[1])
	p = 0
	if k % (n - 1) == 0:
		p = k // (n - 1)
	else:
		p = k // (n - 1) + 1
	print(k + p - 1)


t = int(input())

def solve():
	(n, k) = map(int, input().split())
	p = (k - 1) // (n - 1)
	q = p * n
	ans = k - p * (n - 1) + q
	return ans
ans = []
for i in range(t):
	ans.append(solve())
for a in ans:
	print(a)


t = int(input())
for _ in range(t):
	(n, k) = list(map(int, input().split()))
	dl = k % (n - 1)
	tmo = k // (n - 1)
	if dl == 0:
		print(n * tmo + dl - 1)
	else:
		print(n * tmo + dl)


n = int(input())
for i in range(n):
	(number, k) = [int(x) for x in input().split()]
	counter = k + k // (number - 1)
	if counter % number == 0:
		counter -= 1
	print(counter)
	continue


from collections import defaultdict as dfd
import math
import sys

def II():
	return int(sys.stdin.readline())

def MI():
	return map(int, sys.stdin.readline().split())

def LI():
	return list(map(int, sys.stdin.readline().split()))

def LLI(rows_number):
	return [LI() for _ in range(rows_number)]

def main():
	for _ in range(int(input())):
		(n, k) = map(int, input().split())
		val = k // n
		if n > k:
			print(k)
		elif n == k:
			print(k + 1)
		else:
			temp = val
			k += val
			val = k // n
			while val - temp != 0:
				k += val - temp
				temp = val
				val = k // n
			print(k)
main()


import os
import sys
from io import BytesIO, IOBase
input = sys.stdin.readline

def inp():
	return int(input())

def inlt():
	return list(map(int, input().split()))

def insr():
	s = input()
	return list(s[:len(s) - 1])

def invr():
	return map(int, input().split())

def main():
	try:
		for _ in range(inp()):
			(n, k) = invr()
			(a, b) = divmod(k, n - 1)
			ans = a * n + b
			if ans % n == 0:
				ans -= 1
			print(ans)
	except Exception as e:
		raise e
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
input = lambda : sys.stdin.readline().rstrip('\r\n')
main()


T = int(input())
for i in range(T):
	(n, k) = map(int, input().split())
	term = int((k - 1) / (n - 1)) + k
	print(term)


import math
for _ in range(int(input())):
	(n, k) = list(map(int, input().split()))
	z = (k - 1) // (n - 1)
	print(z + k)


import sys
import math as mt

def get_ints():
	return map(int, sys.stdin.readline().strip().split())

def get_array():
	return list(map(int, sys.stdin.readline().strip().split()))

def printwsp(*args):
	return print(*args, end='')

def printsp(*args):
	return print(*args, end=' ')

def printchk(*args):
	return print(*args, end='tst, ')
MOD = int(1000000000.0 + 7)
BABYMOD = 998244353
for _testcases_ in range(int(input())):
	(n, k) = get_ints()
	num = n - 1
	total = k // num
	rem = k % num
	pos = n * total
	if rem == 0:
		pos -= 1
	else:
		pos += rem
	print(pos)


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


t = int(input())
for i in range(t):
	(n, k) = map(int, input().split())
	if k > n:
		d = k // n
		res = k + d
		while d != res // n:
			old_d = d
			d = res // n
			res += d - old_d
		print(res)
		continue
	elif k == n:
		print(k + 1)
		continue
	else:
		print(k)


import math

def function(n, k):
	x = int(math.floor(k / (n - 1)))
	if (k + x) % n == 0:
		return k + x - 1
	else:
		return k + x
t = int(input())
for k1 in range(t):
	(n, k) = map(int, input().rstrip().split())
	print(function(n, k))


for i in range(int(input())):
	(a, b) = map(int, input().split())
	(d, e) = (1, 0)
	while d != 0:
		c = b // a
		d = c - e
		b = b + d
		e = c
	print(b)


import math
for x in range(int(input())):
	(n, k) = [int(i) for i in input().split()]
	if n == k:
		print(str(n + 1))
	else:
		print(math.ceil(n * k / (n - 1) - 1))


for _ in range(int(input())):
	(n, k) = map(int, input().split())
	cyclesdone = k // (n - 1)
	offset = n * cyclesdone
	if k % (n - 1) == 0:
		print(offset - 1)
	else:
		print(offset + k % (n - 1))


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


try:
	import math
	t = int(input())
	while t >= 0:
		(n, k) = map(int, input().split())
		m = math.floor((k - 1) // (n - 1))
		print(m + k)
except:
	pass


t = int(input())
n = []
k = []
for i in range(t):
	(ni, ki) = input().split()
	n.append(int(ni))
	k.append(int(ki))

def f(n, k):
	m = n - 1
	t = k // m
	if k % m != 0:
		print(t * n + k % m)
	else:
		print(t * n - 1)
for i in range(t):
	f(n[i], k[i])


from math import *
from collections import *
from itertools import *
from bisect import *

def io():
	return map(int, input().split())

def op():
	return list(map(int, input().split()))

def kl(con, x=0):
	if x == 0:
		print('Yes') if con else print('No')
	elif x == 1:
		print('yes') if con else print('no')
	elif x == 2:
		print('YES') if con else print('NO')
MOD = 1000000007
MAX = 2147483647
MIN = -2147483648
p = input
for _ in range(int(p())):
	l = []
	(a, b) = io()
	a -= 1
	if b % a == 0:
		print(b + b // a - 1)
	else:
		print(b + b // a)


t = int(input())
for _ in range(t):
	(n, k) = [int(x) for x in input().split()]
	m = (k - 1) % (n - 1)
	d = (k - 1) // (n - 1)
	res = 1 + d * n + m
	print(res)


import math
no = int(input())
inList = []
mainList = []
for i in range(0, no):
	temp = []
	(a, b) = input().split()
	a = int(a)
	b = int(b)
	temp.append(a)
	temp.append(b)
	inList.append(temp)
for i in inList:
	a = i[1] + math.floor((i[1] - 1) / (i[0] - 1))
	print(a)


from sys import stdin

def inp():
	return stdin.buffer.readline().rstrip().decode('utf8')

def itg():
	return int(stdin.buffer.readline())

def mpint():
	return map(int, stdin.buffer.readline().split())
DEBUG = False

def solve():
	(m, k) = mpint()
	if k < m:
		return k
	t = (k - m) // (m - 1)
	ans = m * t
	count = (m - 1) * t
	if DEBUG:
		print(t, ans, count)
	if k - count < m:
		return ans + (k - count)
	return ans + (k - count) + 1
for case in range(itg()):
	print(solve())


for _ in range(int(input())):
	(n, k) = map(int, input().split())
	if k < n:
		print(k)
		continue
	ans = 0
	while k > n:
		ans += k // n * n
		k = k - (k // n * n - k // n)
	if k == n:
		ans += k + 1
	else:
		ans += k
	print(ans)


def kthNonDivisible(n, k):
	print(k + (k - 1) // (n - 1))

def main():
	t = int(input())
	for i in range(t):
		(n, k) = list(map(int, input().split()))
		kthNonDivisible(n, k)
main()


x = int(input())
l = []
for i in range(x):
	(n, k) = map(int, input().split())
	l.append(int(k + (k - 1) / (n - 1)))
print(*l, sep='\n')


n = int(input())
for _ in range(n):
	(n, m) = map(int, input().split())
	p = m + m // n
	while p - p // n != m:
		p += m - (p - p // n)
	print(p)


import math
t = int(input())
while t > 0:
	(n, k) = [int(i) for i in input().split()]
	mn = 0
	mn = math.ceil(k / (n - 1) - 1)
	need = int(k % (n - 1))
	if need == 0:
		need = n - 1
	print(n * mn + need)
	t -= 1


t = int(input())
answers = []
for _ in range(t):
	(n, k) = [int(i) for i in input().split()]
	k = k - 1
	ans = k // (n - 1) * n + 1 + k % (n - 1)
	answers.append(ans)
print(*answers, sep='\n')


ipnl = lambda n: [int(input()) for _ in range(n)]
inp = lambda : int(input())
ip = lambda : [int(w) for w in input().split()]
mp = lambda : map(int, input().split())
for _ in range(int(input())):
	(n, k) = mp()
	m = n - 1
	(a, b) = (k // m, k % m)
	if b == 0:
		print(a * n - 1)
	else:
		print(a * n + b)


for _ in range(int(input())):
	(n, k) = map(int, input().split())
	x = n * k // (n - 1) - 1
	for i in range(x, x + 2):
		if i - i // n == k:
			print(i)
			break


T = int(input())
for _ in range(T):
	(n, k) = list(map(int, input().split(' ')))
	need = (k - 1) // (n - 1)
	ans = k + need
	print(ans)


for _ in range(int(input())):
	(n, k) = map(int, input().split())
	d1 = k % (n - 1)
	if d1 == 0:
		d1 = n - 1
	n2 = 1 + (k - d1) // (n - 1)
	a = d1 + (n2 - 1) * n
	print(a)


def isodd(a):
	if int(a) % 2 == 0:
		return False
	else:
		return True

def iseven(b):
	if int(b) % 2 == 0:
		return True
	else:
		return False
t = input()
solve_list = []
for i in range(int(t)):
	(n, k) = input().split(' ')
	x = int(int(k) - int(int(n) - 1))
	y = int(int(n) - 1)
	if int(k) < int(n):
		solve_list.append(k)
	elif int(k) == int(n):
		solve_list.append(str(int(int(n) + 1)))
	elif int(x) % int(y) == 0:
		z = int(int(x) / int(y) + int(x) + int(n) - 1)
		solve_list.append(z)
	else:
		z = int(int(x) / int(y) + int(x) + int(n))
		solve_list.append(z)
for i in range(len(solve_list)):
	print(solve_list[i])


import bisect
from math import pi
from collections import deque
from math import factorial
from math import log, ceil
from collections import defaultdict
from math import *
from sys import stdin, stdout
import itertools
import os
import sys
import threading
from collections import deque, Counter, OrderedDict, defaultdict
from heapq import *
from fractions import Fraction
mod = int(pow(10, 9) + 7)

def ii():
	return int(input())

def si():
	return str(input())

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

def li1():
	return list(mi())

def fii():
	return int(stdin.readline())

def fsi():
	return str(stdin.readline())

def fmi():
	return map(int, stdin.readline().split())

def fli():
	return list(fmi())
abd = {'a': 0, 'b': 1, 'c': 2, 'd': 3, 'e': 4, 'f': 5, 'g': 6, 'h': 7, 'i': 8, 'j': 9, 'k': 10, 'l': 11, 'm': 12, 'n': 13, 'o': 14, 'p': 15, 'q': 16, 'r': 17, 's': 18, 't': 19, 'u': 20, 'v': 21, 'w': 22, 'x': 23, 'y': 24, 'z': 25}

def getKey(item):
	return item[0]

def sort2(l):
	return sorted(l, key=getKey)

def d2(n, m, num):
	return [[num for x in range(m)] for y in range(n)]

def isPowerOfTwo(x):
	return x and (not x & x - 1)

def decimalToBinary(n):
	return bin(n).replace('0b', '')

def ntl(n):
	return [int(i) for i in str(n)]

def powerMod(x, y, p):
	res = 1
	x %= p
	while y > 0:
		if y & 1:
			res = res * x % p
		y = y >> 1
		x = x * x % p
	return res
graph = defaultdict(list)
visited = [0] * 1000000
col = [-1] * 1000000

def bfs(d, v):
	q = []
	q.append(v)
	visited[v] = 1
	while len(q) != 0:
		x = q[0]
		q.pop(0)
		for i in d[x]:
			if visited[i] != 1:
				visited[i] = 1
				q.append(i)
		print(x)

def make_graph(e):
	d = {}
	for i in range(e):
		(x, y) = mi()
		if x not in d:
			d[x] = [y]
		else:
			d[x].append(y)
		if y not in d:
			d[y] = [x]
		else:
			d[y].append(x)
	return d

def gr2(n):
	d = defaultdict(list)
	for i in range(n):
		(x, y) = mi()
		d[x].append(y)
	return d

def connected_components(graph):
	seen = set()

	def dfs(v):
		vs = set([v])
		component = []
		while vs:
			v = vs.pop()
			seen.add(v)
			vs |= set(graph[v]) - seen
			component.append(v)
		return component
	ans = []
	for v in graph:
		if v not in seen:
			d = dfs(v)
			ans.append(d)
	return ans

def primeFactors(n):
	s = set()
	while n % 2 == 0:
		s.add(2)
		n = n // 2
	for i in range(3, int(sqrt(n)) + 1, 2):
		while n % i == 0:
			s.add(i)
			n = n // i
	if n > 2:
		s.add(n)
	return s

def find_all(a_str, sub):
	start = 0
	while True:
		start = a_str.find(sub, start)
		if start == -1:
			return
		yield start
		start += len(sub)

def SieveOfEratosthenes(n, isPrime):
	isPrime[0] = isPrime[1] = False
	for i in range(2, n):
		isPrime[i] = True
	p = 2
	while p * p <= n:
		if isPrime[p] == True:
			i = p * p
			while i <= n:
				isPrime[i] = False
				i += p
		p += 1
	return isPrime

def dijkstra(edges, f, t):
	g = defaultdict(list)
	for (l, r, c) in edges:
		g[l].append((c, r))
	(q, seen, mins) = ([(0, f, ())], set(), {f: 0})
	while q:
		(cost, v1, path) = heappop(q)
		if v1 not in seen:
			seen.add(v1)
			path = (v1, path)
			if v1 == t:
				return (cost, path)
			for (c, v2) in g.get(v1, ()):
				if v2 in seen:
					continue
				prev = mins.get(v2, None)
				next = cost + c
				if prev is None or next < prev:
					mins[v2] = next
					heappush(q, (next, v2, path))
	return float('inf')

def binsearch(a, l, r, x):
	while l <= r:
		mid = l + (r - 1) // 2
		if a[mid]:
			return mid
		elif a[mid] > x:
			l = mid - 1
		else:
			r = mid + 1
	return -1

def readTree(n):
	adj = [set() for _ in range(n)]
	for _ in range(n - 1):
		(u, v) = map(int, input().split())
		adj[u - 1].add(v - 1)
		adj[v - 1].add(u - 1)
	return adj

def treeOrderByDepth(n, adj, root=0):
	parent = [-2] + [-1] * (n - 1)
	ordered = []
	q = deque()
	q.append(root)
	depth = [0] * n
	while q:
		c = q.popleft()
		ordered.append(c)
		for a in adj[c]:
			if parent[a] == -1:
				parent[a] = c
				depth[a] = depth[c] + 1
				q.append(a)
	return (ordered, parent, depth)
for _ in range(ii()):
	(n, k) = mi()
	ans = 0
	if k < n:
		print(k)
	else:
		n -= 1
		x = k // n
		y = k % n
		if y == 0:
			y -= 1
		print(x * (n + 1) + y)


t = int(input())
while t > 0:
	t = t - 1
	(x, y) = map(int, input().split())
	temp = y % (x - 1)
	if temp == 0:
		temp = -1
	te = x * int(y / (x - 1))
	te = te + temp
	print(te)


from sys import stdin
import collections

def solve(tc):
	(n, k) = map(int, stdin.readline().split())
	kth = k
	prev = 0
	while True:
		cur = kth // n
		if cur > prev:
			kth += cur - prev
			prev = cur
		else:
			break
	print(kth)
LOCAL_TEST = not __debug__
if LOCAL_TEST:
	infile = __file__.split('.')[0] + '-test.in'
	stdin = open(infile, 'r')
tcs = int(stdin.readline().strip())
tc = 1
while tc <= tcs:
	solve(tc)
	tc += 1


import sys
input = sys.stdin.readline
t = int(input())
for i in range(t):
	(n, k) = map(int, input().strip().split())
	e = 0.1
	res = int((k - e) // (n - 1)) + k
	print(res)


import math
t = int(input())
for _ in range(t):
	(n, k) = map(int, input().split())
	if k < n:
		print(k)
		continue
	else:
		var = k
		while True:
			if var - math.ceil(var // n) == k:
				break
			diff = var - var // n
			diff = k - diff
			var += diff
		print(var)


for i in range(int(input())):
	(n, k) = map(int, input().split())
	x = k
	y = k
	while x > n - 1:
		x1 = x % n
		x = x // n
		y = y + x
		x += x1
	if y % n == 0:
		print(y + 1)
	else:
		print(y)


def binary_search(left, right, n, k):
	if left > right:
		return
	mid = (left + right) // 2
	if mid - mid // n == k and mid % n != 0:
		return mid
	elif mid - mid // n == k and mid % n == 0:
		return mid - 1
	if mid - mid // n > k:
		return binary_search(left, mid - 1, n, k)
	return binary_search(mid + 1, right, n, k)
t = int(input())
for you in range(t):
	l = input().split()
	n = int(l[0])
	k = int(l[1])
	print(binary_search(1, 10 ** 18, n, k))


import math
for _ in range(int(input())):
	(n, k) = map(int, input().split())
	r = n - 1
	t = n * math.ceil(k / r) - 1
	if k % r != 0:
		t = t - (r - k % r)
	print(t)


import sys
import os
import time
import collections
from collections import Counter, deque
import itertools
import math
import timeit
import random
import string

def sieve(n):
	if n < 2:
		return list()
	prime = [True for _ in range(n + 1)]
	p = 3
	while p * p <= n:
		if prime[p]:
			for i in range(p * 2, n + 1, p):
				prime[i] = False
		p += 2
	r = [2]
	for p in range(3, n + 1, 2):
		if prime[p]:
			r.append(p)
	return r

def divs(n, start=1):
	divisors = []
	for i in range(start, int(math.sqrt(n) + 1)):
		if n % i == 0:
			if n / i == i:
				divisors.append(i)
			else:
				divisors.extend([i, n // i])
	return divisors

def divn(n, primes):
	divs_number = 1
	for i in primes:
		if n == 1:
			return divs_number
		t = 1
		while n % i == 0:
			t += 1
			n //= i
		divs_number *= t

def flin(d, x, default=-1):
	left = right = -1
	for i in range(len(d)):
		if d[i] == x:
			if left == -1:
				left = i
			right = i
	if left == -1:
		return (default, default)
	else:
		return (left, right)

def ceil(n, k):
	return n // k + (n % k != 0)

def ii():
	return int(input())

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

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

def lcm(a, b):
	return abs(a * b) // math.gcd(a, b)

def prr(a, sep=' '):
	print(sep.join(map(str, a)))

def dd():
	return collections.defaultdict(int)

def ddl():
	return collections.defaultdict(list)
for _ in range(ii()):
	(n, k) = mi()
	t = k // n
	res = k
	while t > 0:
		res += t
		t = res // n - (res - t) // n
	print(res)


T = int(input())
for _ in range(0, T):
	(n, k) = map(int, input().split())
	tt = k // (n - 1)
	if k % (n - 1) != 0:
		tt += 1
	tt2 = tt - 1
	tot = tt2 * (n - 1)
	req = k - tot
	ans = tt2 * n + req
	print(ans)


for _ in range(int(input())):
	(n, k) = [int(x) for x in input().split()]
	if k < n:
		print(k)
	elif k == n:
		print(k + 1)
	elif n == 1:
		print(k)
	else:
		if k % (n - 1) == 0:
			x = k // (n - 1) - 1
		else:
			x = k // (n - 1)
		print(k + x)


import math
t = int(input())
for i in range(t):
	a = [int(s) for s in input().split()]
	n = a[0]
	k = a[1]
	flor = k // (n - 1)
	upp = k - flor * (n - 1)
	x = flor * n + upp
	if upp == 0:
		x -= 1
	print(x)


import sys

def gcd(a, b):
	if a == 0:
		return b
	return gcd(b % a, a)

def divTermCount(a, num):
	return num - num // a

def findNthTerm(a, n):
	low = 1
	high = sys.maxsize
	while low < high:
		mid = low + (high - low) // 2
		if divTermCount(a, mid) < n:
			low = mid + 1
		else:
			high = mid
	return low
for _ in range(int(input())):
	(a, n) = map(int, input().split())
	ans = findNthTerm(a, n)
	print(ans)


from math import floor
tot = 0
cases = int(input())
for _ in range(cases):
	(n, k) = map(int, input().split())
	a = floor(k / (n - 1))
	b = k % (n - 1)
	if b == 0:
		b = b - 1
	print(a * n + b)


t = int(input())
for case in range(t):
	(n, k) = [int(x) for x in input().split()]
	need = (k - 1) // (n - 1)
	print(k + need)


from sys import stdin, stdout, setrecursionlimit
for _ in range(int(input())):
	(n, k) = map(int, input().split())
	x = k % (n - 1)
	if x == 0:
		x -= 1
	y = k // (n - 1)
	print(n * y + x)


t = int(input())
for i in range(0, t):
	(n, k) = input().strip().split()
	(n, k) = (int(n), int(k))
	x = int(k / (n - 1))
	rem = k - x * (n - 1)
	if rem == 0:
		print(x * n - 1)
	else:
		print(x * n + rem)


from sys import stdin, stdout
rl = lambda : stdin.readline()
rll = lambda : stdin.readline().split()
rli = lambda : map(int, stdin.readline().split())

def main():
	T = int(rl())
	for _ in range(T):
		(n, k) = rli()
		(q, r) = divmod(k, n - 1)
		curr = (n - 1) * q
		if curr == k:
			ans = q * n - r - 1
			print(ans)
			continue
		else:
			m1 = (q + 1) * (n - 1)
			m2 = (q + 1) * n - 1
			diff = m1 - k
			ans = m2 - diff
			print(ans)
	stdout.close()
main()


for _ in ' ' * int(input()):
	(n, k) = input().split()
	(n, k) = (int(n), int(k))
	print(k + (k - 1) // (n - 1))


import math
test_cases = int(input())
for _ in range(test_cases):
	(n, k) = map(int, input().split())
	group = (math.ceil(k / (n - 1)) - 1) * n
	group_index = k % (n - 1)
	if group_index == 0:
		group_index = n - 1
	print(group + group_index)


def k_th_not_divisible_n(n, k):
	return k + (k - 1) // (n - 1)
num_testes = int(input())
for i in range(num_testes):
	(n, k) = map(int, input().split(' '))
	print(k_th_not_divisible_n(n, k))


t = int(input())
while t:
	t -= 1
	(n, k) = list(map(int, input().split()))
	l = 1
	h = 2 * k
	while l < h:
		m = (l + h) // 2
		if m - m // n >= k:
			h = int(m)
			continue
		else:
			l = int(m) + 1
	print(h)


for t in range(int(input())):
	(n, k) = map(int, input().split())
	skip_prev = k // n
	skip_nxt = (k + skip_prev) // n
	while skip_prev != skip_nxt:
		skip_prev = skip_nxt
		skip_nxt = (k + skip_prev) // n
	print(k + skip_nxt)


test = int(input())
for i in range(0, test):
	(n, k) = map(int, input().split())
	if k == 1:
		print(1)
	elif n == k:
		print(n + 1)
	elif k % (n - 1) == 0:
		val = k // (n - 1)
		print(n * val - 1)
	else:
		val = k // (n - 1)
		rem = k % (n - 1)
		print(n * val + rem)


import math
t = int(input())
for _ in range(t):
	(n, k) = map(int, input().split())
	not_div = n - 1
	if k <= n - 1:
		print(k)
		continue
	else:
		k -= n - 1
		fin = n * (k // (n - 1) + 1) + k % (n - 1)
		if fin % n == 0:
			fin -= 1
	print(fin)


x = int(input())
for i in range(x):
	(n, k) = map(int, input().split())
	t = k // n
	j = t
	while t != 0:
		k += t
		t = k // n
		s = t
		t = t - j
		j = s
	print(k)


import math
n = int(input())

def get_result(n, k):
	c = math.ceil(k / (n - 1))
	prev_lim = n * (c - 1)
	full_total = prev_lim // n * (n - 1)
	print(prev_lim + (k - full_total))
for j in range(n):
	(n, k) = map(int, input().split())
	get_result(n, k)


t = int(input())
for ii in range(t):
	(n, k) = list(map(int, input().split()))
	x = k // (n - 1)
	if k % (n - 1) == 0:
		print(x * n - 1)
	else:
		print(x * n + k % (n - 1))


from math import ceil

def solve():
	t = int(input())
	for i in range(t):
		(n, k) = [int(s) for s in input().split()]
		if k >= n:
			k2 = k
			while True:
				s = k2 // n
				if k2 - s >= k:
					l = k
					r = k2
					while l + 1 < r:
						mid = (l + r) // 2
						s = mid // n
						if mid - s >= k:
							r = mid
						else:
							l = mid
					if r % n == 0:
						print(r - 1)
					else:
						print(r)
					break
				else:
					k2 += s
		else:
			print(k)
solve()


from math import ceil
t = int(input())
for _ in range(t):
	(n, k) = map(int, input().split())
	x = ceil(k / (n - 1)) - 1
	y = k % (n - 1)
	if y == 0:
		y = n - 1
	ans = x * n + y
	print(ans)


import math

def solve():
	(n, k) = map(int, input().split())
	term = math.ceil(k / (n - 1))
	back = (n - 1) * term - k + 1
	print(n * term - back)
t = int(input())
for _ in range(t):
	solve()


from sys import stdin, stdout
import bisect

def main():
	for _ in range(int(stdin.readline())):
		(n, k) = map(int, stdin.readline().split())
		if k % (n - 1) == 0:
			d = k // (n - 1)
		else:
			div = k + 1
			d = k // (n - 1) + 1
		rem = k - (d - 1) * (n - 1)
		take = 1
		print(n * (d - 1) + rem)
main()


import sys
t = int(input())
for i in range(t):
	(n, k) = map(int, sys.stdin.readline().strip().split())
	(m, r) = divmod(k, n - 1)
	print(n * m + r if r else n * m - 1)


q = int(input())
for _ in range(q):
	(n, t) = [int(x) for x in input().split()]
	par = t // (n - 1)
	num = par * (n - 1)
	last = par * n - 1
	rem = t - num
	if rem != 0:
		last += rem + 1
	print(last)


t = int(input())
for _ in range(t):
	(n, k) = map(int, input().split())
	x = k // (n - 1)
	c = x * n
	if k % (n - 1) == 0:
		print(c - 1)
	else:
		print(c + k % (n - 1))


import math

def solve(n, k):
	print(math.floor((k - 1) / (n - 1)) + k)
i = int(input())
for k in range(i):
	j = input().split(' ')
	arr = list(map(int, j))
	solve(arr[0], arr[1])


for _ in range(int(input())):
	(n, k) = list(map(int, input().split()))
	num = k // (n - 1)
	if k % (n - 1) == 0:
		ans = num * n - 1
	else:
		ans = num * n + k % (n - 1)
	print(ans)


from sys import stdin
from math import ceil

def iinput():
	return int(stdin.readline())

def minput():
	return map(int, stdin.readline().split())

def linput():
	return list(map(int, stdin.readline().split()))
t = iinput()
while t:
	t -= 1
	(n, k) = minput()
	(low, up) = (k // (n - 1), ceil(k / (n - 1)))
	(l, r) = (n * low + 1, n * up - 1)
	if low == up:
		print(r)
	else:
		i = n * low - low
		print(l + k - i - 1)


import math
t = int(input())
for _ in range(t):
	(n, k) = [int(x) for x in input().split()]
	if n == k:
		print(n + 1)
		continue
	if k == 1:
		print('1')
		continue
	if k % (n - 1) == 0:
		print(n * (k // (n - 1)) + k % (n - 1) - 1)
	else:
		print(n * (k // (n - 1)) + k % (n - 1))


for _ in range(int(input())):
	(n, k) = map(int, input().split())
	l = 1
	r = int(10000000000.0)
	ans = -1
	while l < r:
		m = (l + r) // 2
		t = m - m // n
		if t == k and m % n:
			ans = m
			break
		if t >= k:
			r = m
		else:
			l = m + 1
	print(ans)


for _ in range(int(input())):
	(n, k) = map(int, input().split())
	a = n - 1
	x = a
	cnt = 1
	if k % a == 0:
		cnt = k // a
	else:
		cnt = k // a + 1
	x *= cnt
	val = n * cnt
	if x == k:
		print(val - 1)
	else:
		xval = val - x
		xval += k % x - 1
		print(xval)


def problemC(n, k):
	if k < n:
		print(k)
	else:
		gioi_han = k // (n - 1)
		if k % (n - 1) == 0:
			print(gioi_han * n - 1)
		else:
			print(k + gioi_han)
t = int(input())
for i in range(t):
	(n, k) = [int(x) for x in input().split()]
	problemC(n, k)


t = int(input())
a = []
for i in range(t):
	(ni, ki) = map(int, input().split())
	if ki % (ni - 1) == 0:
		numi = ki // (ni - 1) * ni - 1
	else:
		numi = ki // (ni - 1) * ni + ki % (ni - 1)
	a.append(numi)
for i in range(t):
	print(a[i])


t = int(input())
for _ in range(t):
	(n, k) = map(int, input().split())
	temp = k // (n - 1)
	base = temp * n
	rem = k % (n - 1)
	if rem == 0:
		total = base + rem - 1
	else:
		total = base + rem
	print(total)


import math
t = int(input())
for w in range(t):
	(n, k) = (int(i) for i in input().split())
	k1 = math.ceil(k / (n - 1))
	n1 = n * (k1 - 1)
	if k % (n - 1) == 0:
		print(n1 + (n - 1))
	else:
		print(n1 + k % (n - 1))


n = int(input())
for i in range(n):
	(n, k) = [int(x) for x in input().split()]
	passed = k // (n - 1)
	remaining = k % (n - 1)
	if remaining == 0:
		ans = passed * n - 1
	else:
		ans = passed * n + remaining
	print(ans)


def nondiv(n, k):
	return int(k + int(k - 1) / (n - 1))
t = int(input())
for i in range(t):
	(n, k) = input().split()
	(a, b) = (int(n), int(k))
	print(nondiv(a, b))


import math
T = int(input())
while T != 0:
	(n, k) = map(int, input().split())
	count = 0
	index = 0
	x = math.floor(k / (n - 1))
	if (x + k) % n == 0:
		ans = x + k - 1
	else:
		ans = x + k
	print(ans)
	T -= 1


for t in range(int(input())):
	(n, k) = map(int, input().split())
	p = k // (n - 1)
	r = k % (n - 1)
	if r == 0:
		r = -1
	s = p * n + r
	print(s)


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


t = int(input())
for x in range(t):
	(n, k) = map(int, input().split())
	(l, r, ans) = (1, int(1000000000000.0), 0)
	while l <= r:
		mid = (l + r) // 2
		if mid - mid // n >= k:
			ans = mid
			r = mid - 1
		else:
			l = mid + 1
	print(ans)


try:
	for _ in range(int(input())):
		(n, k) = [int(i) for i in input().split()]
		print(k + (k - 1) // (n - 1))
except:
	pass


for _ in range(int(input())):
	(a, b) = map(int, input().split())
	inti = b // (a - 1)
	remainder = b % (a - 1)
	if remainder == 0:
		print(a * inti - 1)
	else:
		print(a * inti + remainder)


t = int(input())
for i in range(t):
	(a, b) = input().split()
	a = int(a)
	b = int(b)
	ans = b
	y = (b - 1) // (a - 1)
	print(ans + y)


for _ in range(int(input())):
	(n, k) = map(int, input().split())
	l = 1
	r = 10 ** 9
	while l != r:
		mid = (l + r) // 2
		if n * mid + 1 - mid > k:
			r = mid
		else:
			l = mid + 1
	print(k + (l - 1))


from sys import stdin, stdout
from math import *
for __ in range(int(input())):
	(n, k) = map(int, input().split())
	l = 1
	r = 1000000000
	ans = 0
	while l <= r:
		m = (l + r) // 2
		if m * n - m > k:
			r = m - 1
		else:
			ans = m
			l = m + 1
	num = ans * n - ans
	if k < n:
		print(k)
		continue
	if k - num == 0:
		print(n * ans - 1)
	else:
		print(n * ans + (k - num))


from collections import defaultdict
import sys
input = sys.stdin.readline
inf = 100000000000000000
mod = 998244353
for CASES in range(int(input())):
	(n, k) = map(int, input().split())
	if n > k:
		print(k)
		continue
	ans = k // (n - 1) * n + k % (n - 1)
	if k % (n - 1) == 0:
		ans -= 1
	print(ans)


t = int(input())
for test in range(t):
	(n, k) = [int(x) for x in input().split()]
	import math
	deckp = int(math.ceil(k / (n - 1)))
	st = n * (deckp - 1)
	k -= (n - 1) * (deckp - 1)
	print(st + k)


for i in range(int(input())):
	(n, k) = map(int, input().split())
	integer = int(k / (n - 1))
	mod = k % (n - 1)
	if mod == 0:
		print(integer * n - 1)
	else:
		print(integer * n + mod)


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


from math import ceil
for _ in range(int(input())):
	(n, k) = [int(i) for i in input().split()]
	x = ceil(k / (n - 1))
	y = int(x * n)
	y -= 1
	z = int(x * (n - 1))
	p = int(z - k)
	print(y - p)


N = int(input())
answers = []
for i in range(N):
	(x, y) = map(int, input().split())
	number = 1
	rate = x - 2
	dist = y - 1
	number += 1 / (rate + 1) * dist * 2 + (1 - 1 / (rate + 1)) * dist
	answers.append(int(number))
for i in answers:
	print(i)


t = int(input())
for _ in range(t):
	(n, k) = map(int, input().split(' '))
	count = k
	while k >= n:
		y = k % n
		k = k // n
		count += k
		k = k + y
	print(count)


for _ in range(int(input())):
	(n, k) = map(int, input().split())
	if k < n:
		num = k
	else:
		num = n * (k // (n - 1) - 1)
		k -= (n - 1) * (k // (n - 1) - 1)
		while k:
			if k >= n:
				num += n
				k -= n - 1
			else:
				num += k
				k = 0
	print(num)


for t in range(int(input())):
	(n, k) = list(map(int, input().split()))
	a = n * k // (n - 1)
	if k == 0 or n == 0:
		print(0)
		continue
	if k == 1:
		print(1)
		continue
	if k < n:
		print(k)
		continue
	if n * k % a == 0:
		print(a - 1)
	else:
		print(a)


def single_integer():
	return int(input())

def multi_integer():
	return map(int, input().split())

def string():
	return input()

def multi_string():
	return input().split()
t = single_integer()
for i in range(t):
	(n, k) = multi_integer()
	if k % (n - 1) == 0:
		ans = k // (n - 1) * n - 1
		print(ans)
	else:
		ans = k // (n - 1) * n + k % (n - 1)
		print(ans)


import math, sys
import heapq
from fractions import Fraction
from collections import Counter, defaultdict

def li():
	return list(map(int, sys.stdin.readline().split()))

def ls():
	return list(map(int, list(input())))

def la():
	return list(input())

def ii():
	return int(input())

def dic(x):
	return defaultdict(lambda : x)

def isPrime(n):
	i = 2
	if n == 1:
		return False
	while i <= int(math.sqrt(n)):
		if n % i == 0:
			return False
		i = i + 1
	return True

def gcd(a, b):
	if b == 0:
		return a
	return gcd(b, a % b)

def LCM(a, b):
	return a * b / gcd(a, b)
t = int(input())
for _ in range(t):
	(n, k) = li()
	a = k // (n - 1)
	r = k % (n - 1)
	ans = a * n
	if r == 0:
		print(ans - 1)
	else:
		print(ans + r)


import math
t = int(input())
for _ in range(0, t):
	(n, k) = map(int, input().split(' '))
	need = math.floor((k - 1) // (n - 1))
	print(k + need)


def solution(t):
	for i in range(t):
		nm = input().split()
		(n, m) = (int(nm[0]), int(nm[1]))
		print(n * (m // (n - 1)) + (m % (n - 1) if m % (n - 1) else -1))
solution(int(input()))


import sys, math, bisect
from collections import Counter, defaultdict as dd

def data():
	return sys.stdin.readline().strip()

def out(var):
	sys.stdout.write(str(var))

def l():
	return list(sp())

def strl():
	return list(strsp())

def sp():
	return map(int, data().split())

def strsp():
	return map(str, data().split())
for _ in range(int(data())):
	(n, k) = sp()
	if n > k:
		print(k)
	else:
		print(k + math.floor((k - 1) / (n - 1)))


import math
import sys
from collections import defaultdict, Counter, deque, OrderedDict
import bisect
input = iter(sys.stdin.buffer.read().decode().splitlines()).__next__
ilele = lambda : map(int, input().split())
alele = lambda : list(map(int, input().split()))

def list2d(a, b, c):
	return [[c] * b for i in range(a)]
from itertools import accumulate, groupby
import sys
for _ in range(int(input())):
	(n, k) = ilele()
	if k < n:
		print(k)
	else:
		a = (k - 1) // (n - 1)
		print(k + a)


import sys, os
from collections import defaultdict, deque
from math import ceil, floor
if sys.version_info[1] >= 5:
	from math import gcd
else:
	from fractions import gcd
sys.setrecursionlimit(10 ** 6)
write = sys.stdout.write
dbg = (lambda *something: print(*something)) if 'TERM_PROGRAM' in os.environ else lambda *x: 0

def main(given=sys.stdin.readline):
	input = lambda : given().rstrip()
	LMIIS = lambda : list(map(int, input().split()))
	II = lambda : int(input())
	MOD = 10 ** 9 + 7
	t = II()
	for _ in range(t):
		(n, k) = map(int, input().split())
		print(k // (n - 1) * n + (-1 if k % (n - 1) == 0 else k % (n - 1)))
main()


t = int(input())
a = []
for i in range(t):
	n = str(input())
	a.append(n)
for i in a:
	b = i.split(' ')
	n = int(b[0])
	k = int(b[1])
	x = k + (k - 1) // (n - 1)
	print(x)


t = int(input())
for i in range(0, t):
	(n, k) = map(int, input().split())
	r = k
	q = k // n
	while q != 0:
		r += q
		rem = k % n
		k = q + rem
		q = k // n
	print(r)


for i in range(int(input())):
	(n, k) = input().split()
	(n, k) = (int(n), int(k))
	if not k % (n - 1):
		r = int(k / (n - 1))
		ans = n * r - 1
	else:
		s = k % (n - 1)
		r = int(k / (n - 1))
		ans = n * r + s
	print(ans)


def solve(n, k):
	res = 0
	num = k
	while True:
		x = k // n
		diff = abs(x - res)
		if diff == 0:
			break
		res += diff
		k = k + diff
	return num + res
for _ in range(int(input())):
	(n, k) = map(int, input().split())
	result = solve(n, k)
	print(result)


for i in range(int(input())):
	(n, k) = map(int, input().split())
	c = k // (n - 1)
	c2 = k % (n - 1)
	if c2:
		print(n * c + c2)
	else:
		print(n * c - 1)


import math
t = int(input())
for i in range(t):
	(n, k) = [int(f) for f in input().split()]
	ans = math.ceil(k / (n - 1)) - 1
	print(k + ans)


import math
I = lambda : list(map(int, input().split()))
t = I()[0]
while t:
	t -= 1
	(n, k) = I()
	a = math.ceil(k / (n - 1))
	b = (n - 1) * a
	c = n * a - 1
	d = b - k
	print(c - d)


def solve1():
	(n, k) = map(int, input().split())
	print((n * k - 1) // (n - 1))
for _ in range(int(input())):
	solve1()


for _ in range(int(input())):
	(n, k) = map(int, input().split())
	r = k // (n - 1)
	if k % (n - 1) == 0:
		print(r * n - 1)
		continue
	d = k - r * (n - 1)
	ans = r * n + d
	if ans == n:
		ans += 1
	print(ans)


t = int(input())
for tt in range(t):
	(n, k) = (int(i) for i in input().split())
	num = k // n + k
	while True:
		nxt = num // n + k
		if nxt == num:
			break
		num = nxt
	print(num)


for case in range(int(input())):
	(n, k) = map(int, input().split())
	out = k
	bad = k // n
	while bad > 0:
		one = False
		if out % n + bad % n >= n:
			one = True
		out += bad
		if one:
			bad = bad // n + 1
		else:
			bad = bad // n
	print(out)


def solve(n, k):
	aux = k - 1
	while True:
		op = aux - aux // n
		if op == k:
			return aux
		elif op < k:
			aux += k - op
		else:
			aux -= op - k
t = int(input())
for i in range(t):
	(n, k) = list(map(int, input().split()))
	print(solve(n, k))


import random
import math
LI = lambda : list(map(int, input().split()))
MI = lambda : map(int, input().split())
yes = lambda : print('Yes')
no = lambda : print('No')
I = lambda : list(input())
J = lambda x: ''.join(x)
II = lambda : int(input())
SI = lambda : input()
t = II()
for q in range(t):
	(n, k) = MI()
	temp = k // (n - 1) * n
	if k % (n - 1) == 0:
		print(temp - 1)
	else:
		print(temp + k % (n - 1))


t = int(input())
for i in range(1, t + 1):
	a = input().split()
	n = int(a[0])
	k = int(a[1])
	z = k // n
	m = k + z
	w = m // n
	while z != w:
		z = w
		m = k + z
		w = m // n
	print(m)


import math
import os
import random
import re
import sys

def printarr(arr):
	for z in arr:
		if type(z) is list:
			for k in z:
				print(k, end=' ')
		else:
			print(z, end=' ')
	print(end='\n')

def solve(n, k):
	c1 = n * k
	den = n - 1
	ans = math.floor(c1 / den)
	if ans % n == 0:
		ans -= 1
	print(ans)
t = int(input())
while t > 0:
	ins = list(input().split())
	n = int(ins[0])
	k = int(ins[1])
	t -= 1
	solve(n, k)


t = int(input())
for tests in range(t):
	[n, k] = input().split()
	n = int(n)
	k = int(k)
	k -= 1
	q = int(k / (n - 1))
	r = k % (n - 1)
	print(int(q * n + r + 1))


for j in range(int(input())):
	(n, k) = map(int, input().split())
	k += k // (n - 1)
	if not k % n:
		k -= 1
	print(k)


t = int(input())
while t > 0:
	(n, k) = [int(x) for x in input().split()]
	lower = k // (n - 1)
	upper = lower + 1
	low = n * lower
	up = n * upper
	st = n * lower - lower
	if st == k:
		print(low - 1)
	else:
		print(low + (k - st))
	t -= 1


import sys
import math
from collections import defaultdict

def solve(test):
	(n, k) = map(int, input().split())
	s = k // n
	res = k + s
	while res // n - s != 0:
		temp = res // n - s
		res += res // n - s
		s += temp
	print(res)
test_cases = int(input())
for t in range(1, test_cases + 1):
	solve(t)


I = input
for _ in range(int(I())):
	(n, k) = map(int, I().split())
	prev = 0
	r = k
	while r // n - prev:
		t = r // n - prev
		prev = r // n
		r += t
	print(r)


from math import floor, ceil

def solve(n, k):
	nums_between = n - 1
	if nums_between >= k:
		return k
	a = ceil(k / nums_between)
	cur_num = a * n
	count = a * nums_between
	return cur_num + (k - count - 1)
t = int(input())
for _ in range(t):
	(n, k) = map(int, input().split())
	print(solve(n, k))


def solve(a, b):
	div = (b - 1) // (a - 1)
	return div + b
for i in range(int(input())):
	(a, b) = list(map(int, input().split()))
	print(solve(a, b))


t = int(input())
for g in range(t):
	(n, k) = map(int, input().split())
	d = n - 1
	if k <= d:
		print(k)
	else:
		s = k // d
		os = k % d
		if os == 0:
			print(s * n - 1)
		else:
			print(s * n + os)


import math
import sys
t = int(input())
while t:
	t -= 1
	(n, k) = [int(x) for x in input().split()]
	(l, r) = (1, 10 ** 10)
	while r - l > 1:
		m = r + l >> 1
		if m - m // n <= k:
			l = m
		else:
			r = m
	while l - 1 - (l - 1) // n == k:
		l -= 1
	print(l)


T = int(input())
for t in range(T):
	(n, k) = map(int, input().split())
	s = n - 1
	v = k // s
	o = v * n + k % s
	if k % s == 0:
		o -= 1
	print(o)


t = int(input())
for i in range(0, t):
	(n, k) = map(int, input().strip().split())
	if k % (n - 1) != 0:
		l = k // (n - 1) * n + k % (n - 1)
	else:
		l = k // (n - 1) * n - 1
	print(l)


import sys
input = sys.stdin.readline
import math as m

def inp():
	return int(input())

def inlt():
	return list(map(int, input().split()))

def insr():
	s = input()
	return list(s[:len(s)])

def invr():
	return map(int, input().strip().split())
for _ in range(inp()):
	(n, k) = invr()
	prod = m.floor(k / (n - 1))
	rem = k % (n - 1)
	new_ans = prod * n
	if rem != 0:
		new_ans += rem
	else:
		new_ans -= 1
	print(new_ans)


from sys import stdin
input = lambda : stdin.readline().strip()
from math import ceil, sqrt, factorial, gcd
for _ in range(int(input())):
	(n, k) = map(int, input().split())
	if k < n:
		print(k)
	elif k == n:
		print(n + 1)
	else:
		t = k // (n - 1) * n
		f = k % (n - 1)
		if f == 0:
			print(t - 1)
		else:
			print(t + f)


import sys
import math

def ii():
	return sys.stdin.readline().strip()

def idata():
	return [int(x) for x in ii().split()]

def solve_of_problem():
	(n, k) = idata()
	print(k + (k - 1) // (n - 1))
	return
for ______ in range(int(ii())):
	solve_of_problem()


import sys

def input():
	return sys.stdin.readline().strip()

def list2d(a, b, c):
	return [[c] * b for i in range(a)]

def list3d(a, b, c, d):
	return [[[d] * c for j in range(b)] for i in range(a)]

def list4d(a, b, c, d, e):
	return [[[[e] * d for j in range(c)] for j in range(b)] for i in range(a)]

def ceil(x, y=1):
	return int(-(-x // y))

def INT():
	return int(input())

def MAP():
	return map(int, input().split())

def LIST(N=None):
	return list(MAP()) if N is None else [INT() for i in range(N)]

def Yes():
	print('Yes')

def No():
	print('No')

def YES():
	print('YES')

def NO():
	print('NO')
INF = 10 ** 18
MOD = 10 ** 9 + 7

def bisearch_min(mn, mx, func):
	ok = mx
	ng = mn
	while ng + 1 < ok:
		mid = (ok + ng) // 2
		if func(mid):
			ok = mid
		else:
			ng = mid
	return ok
for _ in range(INT()):
	(N, K) = MAP()
	res = bisearch_min(0, INF, lambda m: m - m // N >= K)
	print(res)


def is_ok(x, n, k):
	cnt = x - x // n
	return cnt >= k

def solve():
	(n, k) = map(int, input().split())
	(ok, ng) = (2 * 10 ** 9 + 9, 0)
	while abs(ok - ng) > 1:
		mid = (ok + ng) // 2
		if is_ok(mid, n, k):
			ok = mid
		else:
			ng = mid
	print(ok)
for _ in range(int(input())):
	solve()


def task(n, k):
	reminder = k % (n - 1)
	deltas = k // (n - 1)
	total = deltas * n - 1
	if reminder > 0:
		total += reminder + 1
	print(total)
t = int(input())
for i in range(0, t):
	(n, k) = map(int, input().split())
	task(n, k)


import bisect
import heapq
import math
import random
from collections import Counter, defaultdict, deque
from decimal import ROUND_CEILING, ROUND_HALF_UP, Decimal
from functools import lru_cache, reduce
from itertools import combinations, combinations_with_replacement, product, permutations
from operator import add, mul, sub
import sys
buff_readline = sys.stdin.buffer.readline
readline = sys.stdin.readline
INF = 2 ** 62 - 1

def read_int():
	return int(buff_readline())

def read_int_n():
	return list(map(int, buff_readline().split()))

def read_float():
	return float(buff_readline())

def read_float_n():
	return list(map(float, buff_readline().split()))

def read_str():
	return readline().strip()

def read_str_n():
	return readline().strip().split()

def error_print(*args):
	print(*args, file=sys.stderr)

class Bisect:

	def __init__(self, func):
		self.__func = func

	def bisect_left(self, x, lo, hi):
		while lo < hi:
			mid = (lo + hi) // 2
			if self.__func(mid) < x:
				lo = mid + 1
			else:
				hi = mid
		return lo

	def bisect_right(self, x, lo, hi):
		while lo < hi:
			mid = (lo + hi) // 2
			if x < self.__func(mid):
				hi = mid
			else:
				lo = mid + 1
		return lo

def slv(N, K):
	return Bisect(lambda x: x - x // N).bisect_left(K, 0, 10 ** 10)

def main():
	T = read_int()
	for _ in range(T):
		(N, K) = read_int_n()
		print(slv(N, K))
main()


import sys

def solve(input_path=None):
	if input_path is None:
		f = sys.stdin
	else:
		f = open(input_path, 'r')
	golds = list()
	t = int(f.readline())
	for _ in range(t):
		(n, k) = map(int, f.readline().split())
		need = (k - 1) // (n - 1)
		gold = k + need
		golds.append(f'{gold}')
	return golds

def main():
	for line in solve():
		print(line)
main()


t = int(input())
for _ in range(t):
	(n, k) = map(int, input().split())
	(q1, q2) = (k // (n - 1), k % (n - 1))
	subs = n * q1
	if q2 == 0:
		print(subs - 1)
	else:
		print(subs + q2)


t = int(input())
for i in range(t):
	(n, k) = map(int, input().split())
	mid = int(k / (n - 1))
	temp = n * mid
	abhi = (n - 1) * mid
	req = k - abhi
	if req == 0:
		temp -= 1
	print(temp + req)


def solve():
	(N, K) = [int(el) for el in input().split()]
	times = K // (N - 1)
	while times * N - times < K:
		times += 1
	return (times - 1) * N + K - (times - 1) * (N - 1)
for t in range(1, int(input()) + 1):
	print(solve())


test_cases = int(input())
for _ in range(test_cases):
	(n, k) = [int(x) for x in input().split(' ')]
	temp = k // (n - 1)
	temp1 = n * temp + (k - (n - 1) * temp)
	if k - (n - 1) * temp == 0:
		temp1 -= 1
	print(temp1)


def solve():
	(n, k) = map(int, input().strip().split())
	q = k // (n - 1)
	r = k % (n - 1)
	if r == 0:
		print(q * n - 1)
	else:
		print(q * n + r)
t = int(input())
for tt in range(t):
	solve()


for i in range(int(input())):
	(n, k) = map(int, input().split())
	l = n - 1
	q = k // l
	r = k % l
	if r == 0:
		print(n * q - 1)
	else:
		print(n * q + r)


test = int(input())
respostas = []
for x in range(test):
	(n, k) = map(int, input().split())
	need = (k - 1) // (n - 1)
	respostas.append(k + need)
for x in respostas:
	print(x)


import sys
t = int(sys.stdin.readline())
for _ in range(t):
	(n, k) = map(int, sys.stdin.readline().split())
	cnt = 0
	last = 0
	if k % (n - 1) == 0:
		cnt = k // (n - 1)
		print(cnt * n - 1)
	else:
		cnt = k // (n - 1) + 1
		last = cnt * n - 1
		print(last - (cnt * (n - 1) - k))


import sys
I = sys.stdin.readline
my_ans = ''
for _ in range(int(I())):
	(n, k) = map(int, I().split())
	x = k // n
	ans = k + x
	tmp = k % n + x
	while tmp >= n:
		y = tmp // n
		ans += y
		tmp = y + tmp % n
	my_ans += str(ans) + '\n'
print(my_ans)


for qq in range(int(input())):
	(n, k) = map(int, input().split())
	k += (k + n - 2) // (n - 1) - 1
	print(k)


from sys import stdin, stdout

def main():
	t = int(stdin.readline())
	ans = []
	for _ in range(t):
		(n, k) = map(int, stdin.readline().split(' '))
		if n == k:
			ans.append(n + 1)
			continue
		if k < n:
			ans.append(k)
			continue
		else:
			block = k // (n - 1)
			block += 0 if k == (n - 1) * block else 1
			before = (n - 1) * (block - 1)
			leftover = k - before
			ans.append((block - 1) * n + leftover)
	stdout.write('\n'.join(map(str, ans)))
main()


import math
from collections import Counter, deque
L = lambda : list(map(int, input().split()))
M = lambda : map(int, input().split())
I = lambda : int(input())
IN = lambda : input()
mod = 10 ** 9 + 7

def s(a):
	print(' '.join(list(map(str, a))))
for i in range(I()):
	(n, k) = M()
	b = k
	y = 0
	while True:
		x = b // n
		if x == y:
			break
		b += x - y
		y = x
	print(b)


import math
for tc in range(int(input())):
	(n, k) = map(int, input().split())
	i = math.ceil(k / (n - 1))
	val = n * i
	curr = (n - 1) * i
	print(val - (curr - k) - 1)


t = int(input())
while t:
	(n, k) = map(int, input().strip().split())
	print(int(k + (k - 1) / (n - 1)))
	t -= 1


def check(n, k):
	div = k // n
	number = k
	number1 = number + div
	while number1 // n != number // n:
		temp = number1
		number1 += number1 // n - number // n
		number = temp
	return number1
t = int(input())
i = 0
while i < t:
	arr = list(map(int, input().split()))
	n = check(arr[0], arr[1])
	print(n)
	i += 1


t = int(input())
while t:
	t -= 1
	(n, k) = input().split(' ')
	n = int(n)
	k = int(k)
	x = (k - 1) // (n - 1) + k
	print(x)


t = int(input())
for i in range(t):
	(k, n) = list(map(int, input().split()))
	low = 0
	high = 100000000000
	while low < high:
		mid = low + (high - low) // 2
		if mid - mid // k > n:
			high = mid
		elif mid - mid // k < n:
			low = mid + 1
		else:
			if mid % k == 0:
				print(mid - 1)
			else:
				print(mid)
			break


import math
T = int(input())
for case in range(T):
	(N, K) = map(int, input().split())
	kth = (K - 1) // (N - 1) + K
	print(kth)


for t in range(int(input())):
	(n, k) = map(int, input().split())
	d = k // (n - 1)
	r = k % (n - 1)
	if r:
		print(d * n + r)
	else:
		print(d * n - 1)


def main():
	t = int(input())
	for i in range(t):
		entrada = list(map(int, input().split()))
		n = entrada[0]
		k = entrada[1]
		if n > k:
			print(k)
		else:
			resultado = (n * k - 1) / (n - 1)
			print(int(resultado))
main()


import math
for _ in range(int(input())):
	(n, k) = map(int, input().split())
	l = n - 1
	m = k // l
	tb = k - m * l
	if tb == 0:
		tb = -1
	print(n * m + tb)


z = input
mod = 10 ** 9 + 7
from collections import *
from queue import *
from sys import *
from collections import *
from math import *
from heapq import *
from itertools import *
from bisect import *
from collections import Counter as cc
from math import factorial as f

def lcd(xnum1, xnum2):
	return xnum1 * xnum2 // gcd(xnum1, xnum2)
for _ in range(int(z())):
	(a, b) = map(int, z().split())
	t = (b - 1) // (a - 1)
	print(t + b)


import math
t = int(input())
for x in range(t):
	ar = input().split()
	n = int(ar[0])
	k = int(ar[1])
	mod = k % (n - 1)
	if mod == 0:
		print(k // (n - 1) * n - 1)
	else:
		print(k // (n - 1) * n + 1 * mod)


t = int(input())
while t > 0:
	t -= 1
	inp = input().split(' ')
	n = int(inp[0])
	k = int(inp[1])
	if n <= k:
		ite = k // (n - 1)
		if k % (n - 1) == 0:
			rem = k % (n - 1) - 1
		else:
			rem = k % (n - 1)
		ans = n * ite + rem
		print(ans)
	else:
		print(k)


t = int(input())
for i in range(t):
	(n1, k1) = input().split(' ')
	n = int(n1)
	k = int(k1)
	if k % (n - 1) == 0:
		print(n * (k // (n - 1)) - 1)
	else:
		print(n * (k // (n - 1)) + k % (n - 1))


import math
for _ in range(int(input())):
	(n, k) = map(int, input().split())
	d = math.ceil(k / (n - 1))
	r = n * (d - 1)
	p = (d - 1) * (n - 1)
	h = k - p
	ans = r + h
	print(ans)


t = int(input())
for _ in range(t):
	(n, k) = map(int, input().split(' '))
	rot = k // (n - 1)
	res = k % (n - 1)
	x = res + rot * n
	if x % n == 0:
		x = x - 1
	print(x)


t = int(input())
for testcase in range(t):
	args = input().split()
	n = int(args[0])
	k = int(args[1])
	offset = k // (n - 1)
	ans = offset * n + k % (n - 1)
	if k % (n - 1) == 0:
		ans -= 1
	print(ans)


for _ in range(int(input())):
	(a, b) = [int(x) for x in input().split()]
	ans = b
	c = b
	while c // a != 0:
		ans = ans + c // a
		c = c // a + c % a
	print(ans)


a = int(input())
for i in range(a):
	b = 1
	c = input().split()
	d = int(c[0])
	e = int(c[1])
	if e * (1 + 1 / (d - 1)) % 1 == 0:
		f = int(e * (1 + 1 / (d - 1)) - 1)
	else:
		f = int(e * (1 + 1 / (d - 1)))
	print(f)


T = int(input())
for t in range(T):
	(n, k) = list(map(int, input().split()))
	if k == 1:
		print(1)
		continue
	tempK = n - 1
	q = k // tempK
	rem = k % tempK
	if rem == 0:
		ans = n * q - 1
	else:
		ans = n * q + rem
	print(ans)


n = int(input())
pairs = []
for i in range(n):
	pairs.append([int(x) for x in input().split()])
for pair in pairs:
	(n, k) = pair
	print(n * (k // (n - 1)) + (k % (n - 1) or -1))


import math
t = int(input())

def solve():
	temp = input().split(' ')
	n = int(temp[0])
	k = int(temp[1])
	res = math.ceil(n * k / (n - 1)) - 2
	while res - math.floor(res / n) != k:
		res += 1
	print(res)
for i in range(t):
	solve()


for _ in range(int(input())):
	(n, k) = map(int, input().split())
	j = k // (n - 1)
	c = n * j
	r = k % (n - 1)
	if r == 0:
		print(c - 1)
	else:
		print(c + r)


for _ in range(int(input())):
	(n, k) = map(int, input().split())
	i = k // (n - 1)
	c = k - i * (n - 1)
	if c == 0:
		c = -1
	x = n * i + c
	print(x)


import math
import sys
input = sys.stdin.readline
t = int(input())
for i in range(t):
	(n, k) = map(int, input().split())
	q = k // (n - 1)
	r = k % (n - 1)
	if r == 0:
		print(n * q - 1)
	else:
		print(n * q + r)


for _ in range(int(input())):
	(n, k) = map(int, input().split())
	a = k // (n - 1)
	maxval = n - 1 + (a - 1) * n
	b = maxval // n
	c = a * (n - 1)
	m = k - c
	if (maxval + m) // n <= b:
		maxval += m
	else:
		maxval += m + 1
	print(maxval)


def solve():
	(n, k) = map(int, input().split())
	l = 1
	r = 1000000000
	best = 0
	while l <= r:
		mid = (l + r) // 2
		mult = mid * n
		lft = mult - mid
		if lft < k:
			best = mid
			l = mid + 1
		else:
			r = mid - 1
	mult = best * n
	bf = mult - best
	bf = k - bf
	mult += bf
	print(mult)
	return
t = 1
t = int(input())
while t > 0:
	t -= 1
	solve()


INT_MAX = 10 ** 19 + 7
MOD = 10 ** 12 + 7

def INPUT():
	return list((int(i) for i in input().split()))

def LIST_1D_ARRAY(n):
	return [0 for _ in range(n)]

def LIST_2D_ARRAY(m, n):
	return [[0 for _ in range(n)] for _ in range(m)]
for _ in range(int(input())):
	(n, k) = INPUT()
	block = k // (n - 1)
	ans = block * n + k - (n - 1) * block
	if k % (n - 1) == 0:
		ans -= 1
	print(ans)


from collections import deque
t = int(input())
rez = []
for i in range(t):
	A = input().split()
	n = int(A[0])
	k = int(A[1])
	r = n - 1
	if k % (n - 1) == 0:
		rez.append(k + int(k // (n - 1)) - 1)
	else:
		rez.append(k + int(k // (n - 1)))
for i in range(len(rez)):
	print(rez[i])


import sys
reader = (s.rstrip() for s in sys.stdin)
input = reader.__next__

def gift():
	for _ in range(t):
		(n, k) = map(int, input().split())
		if k % (n - 1):
			yield (k // (n - 1) * n + k % (n - 1))
		else:
			yield (k // (n - 1) * n - 1)
t = int(input())
ans = gift()
print(*ans, sep='\n')


for _ in range(int(input())):
	(n, k) = map(int, input().split())
	takes = k // (n - 1)
	res = takes * n
	res += k - takes * (n - 1)
	if k % (n - 1) == 0:
		res -= 1
	print(res)


import math
for _ in range(int(input())):
	(n, k) = map(int, input().split())
	added = (k - 1) // (n - 1)
	print(k + added)


for _ in range(int(input())):
	(n, k) = map(int, input().split())
	rem = n - 1
	div = k // rem
	addit = k - div * rem
	if addit == 0:
		addit = -1
	c = div * n
	print(c + addit)


for _ in range(int(input())):
	(n, k) = map(int, input().split())
	if k < n:
		print(k)
	else:
		len = n - 1
		temp = k // len
		addon = k % len
		if addon == 0:
			ans = n * temp - 1
		else:
			ans = n * temp + addon
		print(ans)


from sys import stdin

def main():
	input = lambda : stdin.readline()[:-1]
	T = int(input())
	for _ in [0] * T:
		(N, K) = map(int, input().split())
		(d, m) = divmod(K, N - 1)
		ans = d * N
		if m:
			ans += m
		else:
			ans -= 1
		print(ans)
main()


test = int(input())
for t in range(test):
	(n, k) = map(int, input().split(' '))
	if k % (n - 1) == 0:
		print(int(k / (n - 1) * n - 1))
	else:
		diff = k - k // (n - 1) * (n - 1)
		revk = k // (n - 1) * (n - 1)
		x1 = revk // (n - 1) * n
		print(int(x1 + diff))


import sys
from collections import defaultdict, Counter, deque
from itertools import accumulate, permutations, combinations
from operator import itemgetter
from bisect import bisect_left, bisect_right, bisect
from heapq import heappop, heappush
from fractions import gcd
from math import ceil, floor, sqrt, cos, sin, pi
from copy import deepcopy

def main():
	(n, k) = map(int, input().split())
	q = (k - 1) % (n - 1)
	a = n * k - 1 - q
	return a // (n - 1)
t = int(input())
for _ in range(t):
	print(main())


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

	def place(x):
		return x - x // n
	left = 1
	p_left = place(left)
	right = 4000000000
	p_right = place(right)
	while left < right:
		mid = (left + right) // 2
		p_mid = place(mid)
		if p_mid == k and mid % n != 0:
			left = mid
			break
		if p_mid >= k:
			p_right = p_mid
			right = mid
		else:
			p_left = p_mid
			left = mid
	print(left)


from sys import stdin

def quant_div(inicio, fim, n=7):
	if int(inicio / n) != inicio / n:
		ndiv = int(fim / n) - int(inicio / n)
	else:
		ndiv = int(fim / n) - int(inicio / n) + 1
	return ndiv

def quant_not_div(inicio, fim, n):
	return fim - inicio + 1 - quant_div(inicio, fim, n)

def not_div(n=3, k=7):
	count = 0
	inicio = 1
	fim = k
	while count != k:
		count += quant_not_div(inicio, fim, n)
		i = inicio
		inicio = fim + 1
		fim = fim + quant_div(i, fim, n)
	return inicio - 1
t = int(stdin.readline().replace('\n', '').replace(' ', ''))
result = []
for i in range(t):
	(n, k) = stdin.readline().split(' ')
	k = k.replace('\n', '').replace(' ', '')
	result += [not_div(n=int(n), k=int(k))]
for r in result:
	print(r)


def solve():
	(n, k) = list(map(int, input().split()))
	no_of_steps = (k - 1) // (n - 1)
	print(no_of_steps * n + 1 + (k - 1) % (n - 1))
for _t in range(int(input())):
	solve()


def getKnotDivisible(n, k):
	r = (k - 1) // (n - 1)
	return r + k

def run():
	tests = int(input())
	for _ in range(tests):
		(n, k) = list(map(int, input().split()))
		print(getKnotDivisible(n, k))
run()


def call():
	(n, k) = map(int, input().split())
	print(k + (k - 1) // (n - 1))
for i in range(int(input())):
	call()


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


import sys
input = sys.stdin.readline

def main():
	t = int(input())
	for _ in range(t):
		(N, K) = [int(x) for x in input().split()]
		ans = K
		q = -1
		while q != 0:
			(q, r) = divmod(K, N)
			ans += q
			K = r + q
		print(ans)
main()


import math
t = int(input())
for _ in range(t):
	(n, k) = map(int, input().split())
	cur = 1
	if n > k:
		print(k)
	else:
		lo = (math.ceil(k / (n - 1)) - 1) * n + 1
		hi = (math.ceil(k / (n - 1)) - 1) * n + n
		while lo <= hi:
			mid = lo + hi >> 1
			if mid - mid // n == k:
				print(mid)
				break
			if mid - mid // n > k:
				hi = mid - 1
			else:
				lo = mid + 1


import os
import sys
from io import BytesIO, IOBase

def solution(n, k):
	if k == 1:
		write(1)
		return
	div = k // (n - 1)
	near = n * div
	if k % (n - 1) == 0:
		res = near - k % (n - 1) - 1
	else:
		res = near + k % (n - 1)
	write(res)

def main():
	for _ in range(r_int()):
		(a, b) = r_array()
		solution(a, b)
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))

def input():
	return sys.stdin.readline().rstrip('\r\n')

def write(*args, end='\n'):
	for x in args[:-1]:
		sys.stdout.write(str(x) + ' ')
	sys.stdout.write(str(args[-1]))
	sys.stdout.write(end)

def r_array():
	return [int(x) for x in input().split()]

def r_int():
	return int(input())
main()


import math
t = int(input())
ls = []
ls2 = []
for k in range(t):
	(n, k) = map(int, input().split())
	ls.append(n)
	ls2.append(k)
for i in range(t):
	a = ls[i]
	b = ls2[i]
	rem = math.floor((b - 1) / (a - 1))
	print(b + rem)


import collections
import itertools
import sys
from collections import defaultdict, Counter
from math import sqrt, ceil
input = sys.stdin.readline

def inp():
	return int(input())

def inlt():
	return list(map(int, input().split()))

def insr():
	s = input()
	return list(s[:len(s) - 1])

def invr():
	return map(int, input().split())

def c(b, n):
	return b - b // n

def main():
	d = inp()
	for _ in range(d):
		(n, k) = inlt()
		b = k
		while c(b, n) != k:
			r = c(b, n)
			if r > k:
				b -= abs(r - k)
			else:
				b += abs(r - k)
		print(b)
main()


from sys import stdin, stdout
import collections
import heapq
import itertools
import functools
import math
import operator
import string
ALPHABET = string.ascii_lowercase
DIGITS = string.digits

def read_line():
	return stdin.readline().strip()

def read_int():
	return int(read_line())

def read_arr():
	return read_line().split(' ')

def read_int_arr():
	return [int(x) for x in read_arr()]

def query_interactive(s):
	print(s)
	stdout.flush()

def solve():
	(n, k) = read_int_arr()
	num_whole = (k - 1) // (n - 1)
	num_off = (k - 1) % (n - 1) + 1
	print(num_whole * n + num_off)

def main():
	T = 1
	T = read_int()
	for _ in range(T):
		solve()
main()


def div(n, k):
	if n > k:
		return k
	prev = k // n
	ans = k + prev
	d = 1
	while d != 0:
		curr = ans // n
		d = curr - prev
		ans += d
		prev = curr
	return ans
T = int(input())
for i in range(T):
	(n, k) = [int(j) for j in input().split()]
	print(div(n, k))


n = int(input())
for i in range(n):
	(m, k) = input().split()
	m = int(m)
	k = int(k)
	kk = k // (m - 1)
	if k % (m - 1) == 0:
		kk -= 1
	kk = kk * m + (k + kk) % m
	print(kk)


import math
for _ in range(int(input())):
	(n, k) = map(int, input().split())
	gap = math.ceil(k / (n - 1)) - 1
	print(gap * n + (k - (n - 1) * gap))


f = int(input())
for q in range(f):
	(a, b) = map(int, input().split())
	if a <= b:
		print(b + b // (a - 1) + int(b % (a - 1) > 0) - 1)
	else:
		print(b)


t = int(input())
for _ in range(t):
	(n, k) = map(int, input().split())
	(r, p) = ((k - 1) % (n - 1), (k - 1) // (n - 1))
	print(p * n + r + 1)


tc = int(input())
for i in range(tc):
	(n, k) = map(int, input().split())
	result = (k - 1) // (n - 1) + k
	print(result)


t = int(input())
list = []
for i in range(t):
	(n, k) = map(int, input().split())
	need = (k - 1) // (n - 1)
	list.append(k + need)
for i in list:
	print(i)


for _ in range(int(input())):
	(n, k) = map(int, input().split())
	g = n - 1
	j = k // g
	p = k % g
	print(j * n + (p if p != 0 else -1))


quantidade_testes = int(input())
valores = []
for _ in range(quantidade_testes):
	(n, k) = list(map(int, input().split()))
	divisao = int((k - 1) / (n - 1))
	valores.append(k + divisao)
for valor in valores:
	print(valor)


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


tc = int(input())
while tc != 0:
	tc = tc - 1
	(n, k) = map(int, input().split(' '))
	a = k // (n - 1)
	b = k % (n - 1)
	c = n * a
	if b == 0:
		print(c - 1)
	else:
		print(c + b)


import math
for _ in range(int(input())):
	(n, k) = list(map(int, input().split()))
	bSize = n - 1
	window = math.ceil(k / bSize)
	covered = bSize * (window - 1)
	ans = n * (window - 1) + k - covered
	print(ans)


import math
t = int(input())
while t != 0:
	t -= 1
	(n, k) = [int(x) for x in input().split()]
	if k == n:
		print(n + 1)
	elif n == 2:
		print(n * k - 1)
	elif k % (n - 1) == 0:
		print(k // (n - 1) * n - 1)
	else:
		print(k // (n - 1) * n + k % (n - 1))


import sys
cases = int(sys.stdin.readline())
for _ in range(cases):
	(n, k) = sys.stdin.readline().strip().split()
	(n, k) = (int(n), int(k))
	if k % (n - 1) == 0:
		print(n * (k // (n - 1)) + k % (n - 1) - 1)
	else:
		print(n * (k // (n - 1)) + k % (n - 1))


qtd = int(input())
for i in range(qtd):
	linha = input().split()
	n = int(linha[0])
	k = int(linha[1])
	if k < n:
		print(k)
	else:
		nPassos = int(k / (n - 1))
		if (nPassos + k) % n == 0:
			print(nPassos + k - 1)
		else:
			print(nPassos + k)


from sys import stdin
import math

def solve(n, k):
	return k + math.ceil(k / (n - 1)) - 1
ntests = int(stdin.readline())
while len((line := stdin.readline().split())) == 2:
	(n, k) = (int(line[0]), int(line[1]))
	print(solve(n, k))


from math import ceil
for _ in range(int(input())):
	(n, k) = map(int, input().split())
	temp = ceil(k / (n - 1)) - 1
	temp1 = temp * n
	temp2 = temp * (n - 1)
	print(temp1 + (k - temp2))


import math

def ans(a, b):
	c = math.ceil(b / (a - 1)) * (a - 1) - a + math.ceil(b / (a - 1))
	if b % (a - 1) == 0:
		c = c + a - 1
		print(c)
	else:
		c = c + b % (a - 1)
		print(c)
n = int(input())
l2 = []
for i in range(n):
	l2.append([int(x) for x in input().split()])
for i in range(n):
	ans(l2[i][0], l2[i][1])
print()


for _ in range(int(input())):
	(n, k) = map(int, input().split())
	x = k // n
	y = k + x
	while y // n - x != 0:
		f = y // n
		y += y // n - x
		x = f
	print(y)


t = int(input())
for _ in range(t):
	(n, k) = map(int, input().split())
	pre_k = k
	new_k = -1
	while new_k != k:
		new_k = pre_k - pre_k // n
		pre_k = k + pre_k - new_k
	print(pre_k)


def ans(n, k):
	if k < n:
		return k
	return k // n * n + ans(n, k - (k // n * n - k // n))
for i in range(int(input())):
	(n, k) = map(int, input().split())
	print(ans(n, k))


t = int(input())
while t > 0:
	t -= 1
	(n, k) = map(int, input().split())
	low = 0
	high = 10 ** 10
	mid = 0
	ans = 0
	while low <= high:
		mid = (low + high) // 2
		num = mid * (n - 1)
		if num >= k:
			high = mid - 1
		else:
			ans = mid
			low = mid + 1
	print(ans * n + (k - ans * (n - 1)))


INPUT = True

def func(ip_ls):
	n = ip_ls[0]
	k = ip_ls[1]
	if k == 1:
		return 1
	if k % (n - 1) == 0:
		row = int(k / (n - 1))
		index = n - 1
	else:
		row = int(k / (n - 1)) + 1
		index = k % (n - 1)
	value = row * n - (n - index)
	return value
op_ls = []
while INPUT:
	t = input()
	if int(t) <= 10 ** 3 and int(t) >= 1:
		for i in range(int(t)):
			ip_ls = []
			ip = input()
			ip_ls = ip.split()
			ip_ls = list(map(int, ip_ls))
			if ip_ls[0] <= 10 ** 9 and ip_ls[0] >= 2 and (ip_ls[1] <= 10 ** 9) and (ip_ls[1] >= 1):
				op_ls.append(func(ip_ls))
	INPUT = False
for i in op_ls:
	print(i)


import math
T = int(input())
for I in range(0, T):
	X = list(map(int, input().split(' ')))
	A = X[0]
	B = X[1]
	C = (math.ceil(B / (A - 1)) - 1) * A
	D = B - (math.ceil(B / (A - 1)) - 1) * (A - 1)
	print(C + D)


import math
a = int(input())
for i in range(a):
	(n, k) = map(int, input().split())
	print(k + math.floor((k - 1) / (n - 1)))


for i in range(int(input())):
	(n, k) = [int(num) for num in input().split()]
	if k * n % (n - 1) == 0:
		ans = k * n // (n - 1) - 1
		print(ans)
	else:
		ans = k * n // (n - 1)
		print(ans)


import math
t = int(input())
for _ in range(t):
	(n, k) = tuple([int(i) for i in input().split()])
	ub = k * n
	lb = 1
	for x in range(2 * math.ceil(math.log(ub - lb, 2)) + 20):
		nb = (ub + lb) // 2
		if nb - nb // n == k:
			ub = nb
			lb = nb
			break
		if nb - nb // n > k:
			ub = nb
		else:
			lb = nb
	if ub - 1 - (ub - 1) // n == k:
		print(ub - 1)
	elif ub - ub // n == k:
		print(ub)
	elif ub + 1 - (ub + 1) // n == k:
		print(ub + 1)


t = int(input())
for i in range(t):
	(n, k) = map(int, input().split())
	if k < n:
		print(k)
	elif n == 2:
		print(k * n - 1)
	elif k % n == 0 and n != 2:
		b = k // n * n + k // n
		count = k // n
		while b >= (count + 1) * n:
			x = b // n
			b = x - count + b
			count = x
		print(b)
	else:
		a = k + k // n
		temp = k // n
		while a >= (temp + 1) * n:
			z = a // n
			a = z - temp + a
			temp = z
		print(a)


def solution(n, k):
	solu = k // (n - 1)
	modu = k % (n - 1)
	if modu == 0:
		modu = -1
	print(solu * n + modu)
t = int(input())
for i in range(1, t + 1):
	(n, k) = map(int, input().split(' '))
	solution(n, k)


from math import ceil
t = int(input())
for i in range(t):
	(n, k) = [int(x) for x in input().split()]
	i = ceil(k / (n - 1)) - 1
	num = n * i + 1
	answ = (n - 1) * i + 1
	print(num + k - answ)


querys = int(input())
while querys != 0:
	querys -= 1
	(n, k) = map(int, input().split())
	divisors = int((k - 1) / (n - 1))
	print(divisors + k)


t = int(input())
while t:
	(n, k) = map(int, input().split())
	ans = (k - 1) // (n - 1)
	print(ans + k)
	t -= 1


t = int(input())
for v in range(t):
	(n, k) = map(int, input().split(' '))
	span = n - 1
	mul = k // span
	rem = k % span
	val = n * mul
	if rem == 0:
		print(val - 1)
	else:
		print(val + rem)


from math import *
from copy import *
from heapq import *
from string import *
from random import *
from bisect import *
from sys import stdin
from sys import maxsize
from operator import *
from itertools import *
from collections import Counter
from collections import defaultdict

def solve(n, k):
	if k < n:
		print(k)
	else:
		zz = n * (k // (n - 1))
		ans = zz + k % (n - 1)
		if k % (n - 1) == 0:
			ans -= 1
		print(ans)
T = int(input())
for _ in range(T):
	(N, K) = list(map(int, stdin.readline().rstrip().split()))
	solve(N, K)


from sys import stdin, stdout

def multiples(end, div):
	last = end // div * div
	start = div
	if last < start:
		return 0
	return 1 + (last - start) // div
for _ in range(int(stdin.readline())):
	(n, k) = list(map(int, stdin.readline().split()))
	(l, r) = (1, 2 * 10 ** 9 + 1)
	while l <= r:
		mid = (l + r) // 2
		mul = multiples(mid, n)
		if mid - mul > k:
			r = mid - 1
		else:
			l = mid + 1
	if r % n == 0:
		r -= 1
	print(r)


from math import floor
for _ in range(int(input())):
	(n, k) = map(int, input().split())
	if k < n:
		print(k)
	else:
		r = k % (n - 1)
		if r == 0:
			r = -1
		print(r + k // (n - 1) * n)


from sys import stdin
T = int(input())
for _ in range(T):
	(N, K) = map(int, stdin.readline().split())
	(n, r) = divmod(K, N - 1)
	print(K + n - 1 * (r == 0))


t = int(input())

def busca_binaria(n, k):
	left = 0
	right = 2 * k
	while left < right - 1:
		mid = (left + right) // 2
		if mid - mid // n >= k:
			right = mid
		else:
			left = mid
	return right
for i in range(t):
	(n, k) = map(int, input().split())
	print(busca_binaria(n, k))


a = int(input())
for i in range(a):
	(x, y) = map(int, input().split())
	(fin, ini) = (y, 0)
	while fin // x - ini // x != 0:
		dup = fin
		fin = fin + fin // x - ini // x
		ini = dup
	print(fin)


a = int(input())
for i in range(a):
	(n, k) = map(int, input().split())
	d = k
	while 1:
		d = k + d // n
		if d - d // n == k:
			break
	print(d)


import sys
input = lambda : sys.stdin.readline().strip('\r\n')
for _ in range(int(input())):
	(n, k) = map(int, input().split())
	print(k + (k - 1) // (n - 1))


from math import *

def main():
	for _ in range(int(input())):
		(n, k) = map(int, input().split())
		block = k // (n - 1) * n
		if k % (n - 1) == 0:
			block -= 1
		else:
			block += k % (n - 1)
		print(block)
main()


T = int(input())

def solve(n, k):
	return (k - 1) // (n - 1) * n + (k - 1) % (n - 1) + 1
for i in range(T):
	(a, b) = map(int, input().split())
	print(solve(a, b))


import math as m
c = int(input())
for i in range(c):
	flag = 0
	(n, k) = [int(x) for x in input().split()]
	a = k / (n - 1)
	if a == m.floor(a):
		flag = 1
	a = m.floor(n * a)
	if flag:
		a -= 1
	print(a)


from sys import stdin, stdout
from os import path
if path.exists('input.txt'):
	stdin = open('input.txt', 'r')
	stdout = open('output.txt', 'w')

	def I():
		return int(input())

	def In():
		return map(int, input().split())
else:

	def I():
		return int(stdin.readline())

	def In():
		return map(int, stdin.readline().split())

	def S():
		return stdin.readline().rstrip()

	def Sn():
		return stdin.readline().split(' ')
q = I()
answers = ['         '] * q
for i in range(q):
	(n, k) = In()
	answers[i] = str(k + (k - 1) // (n - 1))
stdout.write('\n'.join(answers))


s = int(input())
for j in range(s):
	(n, k) = [int(x) for x in input().split()]
	t = (k - 1) // (n - 1)
	print(k + t)


def func(l):
	for i in range(l):
		b = list(map(int, input().split()))
		n = b[0]
		k = b[1]
		a = (k - 1) // (n - 1)
		print(k + a)
l = int(input())
func(l)


import math
t = int(input())
for case in range(t):
	(n, k) = [int(x) for x in input().split()]
	answer = k + math.floor(k / n)
	rem = k % n + math.floor(k / n)
	while rem / n >= 1:
		oldanswer = answer
		answer += math.floor(rem / n)
		rem = oldanswer % n + math.floor(rem / n)
	print(answer)


def solve(n, k):
	quotient = int(k / (n - 1))
	remainder = int(k % (n - 1))
	if remainder == 0:
		quotient -= 1
		remainder = -1 % n
	num = n * quotient + remainder
	print(num)
testCases = int(input())
while testCases:
	(N, K) = map(int, input().split())
	solve(N, K)
	testCases -= 1


for _ in range(int(input())):
	(n, k) = [int(x) for x in input().split()]
	r = k
	while True:
		x = r - r // n
		if x >= k:
			break
		r = k + r // n
	print(r)


def check(x, n):
	tot = x // n
	return x - tot
for _ in range(int(input())):
	(n, k) = map(int, input().split())
	low = 0
	high = 10 ** 20
	ans = -1
	while low <= high:
		mid = (low + high) // 2
		if check(mid, n) == k:
			ans = mid
			high = mid - 1
		elif check(mid, n) > k:
			high = mid - 1
		else:
			low = mid + 1
	print(ans)


def ndivisores(n, k):
	cont = 0
	ndiv = (k - 1) // (n - 1)
	ndiv += k
	return ndiv
t = int(input())
for e in range(t):
	(n, k) = map(int, input().split())
	print(ndivisores(n, k))


T = int(input())
i = 0
while i < T:
	s = input().split()
	n = int(s[0])
	k = int(s[1])
	t = k // (n - 1)
	if k % (n - 1) == 0:
		print(t * n - 1)
	else:
		print(t * n + max(k % (n - 1), 1))
	i += 1


import math
T = int(input())
for _ in range(T):
	(n, k) = map(int, input().split())
	if k < n:
		print(k)
	else:
		i = (k - n) // (n - 1)
		i += 1
		ans = n * i + (k + i) % n
		print(ans)


from math import floor
for _ in range(int(input())):
	(n, k) = map(int, input().split())
	space = n - 1
	leap = floor(k / space)
	num = 0
	num = leap * n + (k - leap * space)
	if k % space == 0:
		num -= 1
	else:
		num
	print(num)


import math
for _ in range(int(input())):
	(n, k) = map(int, input().split())
	ans = k // (n - 1) + k
	if ans % n == 0:
		ans -= 1
	print(ans)


from math import ceil

def s(n, k):
	return ceil(k / (n - 1) * n)

def run():
	t = int(input())
	for i in range(t):
		(n, k) = map(int, input().split())
		print(s(n, k) - 1)
run()


import copy
t = int(input())
for T in range(t):
	(n, k) = map(int, input().split())
	print((k - 1) // (n - 1) * n + (k - 1) % (n - 1) + 1)


m = int(input())
for i in range(m):
	(n, k) = map(int, input().split())
	p = int(k * n / (n - 1))
	for x in range(p - 2, p + 2):
		if x == k + x // n:
			print(x)
			break


num = int(input())
while num > 0:
	(n, k) = map(int, input().split())
	print((k - 1) // (n - 1) + k)
	num -= 1


import sys
try:
	sys.stdin = open('input.txt', 'r')
	sys.stdout = open('output.txt', 'w')
except:
	pass
input = sys.stdin.readline
for tt in range(int(input())):
	(n, k) = map(int, input().split())
	if k < n:
		print(k)
	else:
		temp = k // (n - 1)
		pos = n * temp
		k -= (n - 1) * temp
		if k == 0:
			pos -= 1
		else:
			pos += k
		print(pos)


t = int(input())
for _ in range(t):
	inp = list(map(int, input().split()))
	n = inp[0]
	k = inp[1]
	r = k % (n - 1)
	p = k // (n - 1)
	if int(r) == 0:
		print(n * p - 1)
	else:
		print(n * p + r)


m = int(input())
while m:
	(n, k) = map(int, input().split())
	print(k + (k - 1) // (n - 1))
	m -= 1


def sol(n, k):
	delta = 2 ** (81 * 4)
	x = 0
	while True:
		number = x // n * (n - 1) + x % n
		if x // n * (n - 1) >= k:
			number += 1
		if number == k:
			return x
		elif number > k:
			x -= delta
		else:
			x += delta
		delta //= 2
t = int(input())
for kek in range(t):
	(n, k) = map(int, input().split())
	print(sol(n, k))


def f(n, k, x):
	if x - x // n >= k:
		return True
	else:
		return False
t = int(input())
for _ in range(t):
	a = [int(el) for el in input().split()]
	n = a[0]
	k = a[1]
	if n == k:
		print(n + 1)
		continue
	if n > k:
		print(k)
		continue
	l = 0
	r = 10000000000
	while r - l > 1:
		m = (l + r) // 2
		if f(n, k, m):
			r = m
		else:
			l = m
	print(r)


import math

def kthNonDivisible(N, K):
	return K + math.floor((K - 1) / (N - 1))
t = int(input())
lst = []
for i in range(t):
	(N, K) = input().split()
	N = int(N)
	K = int(K)
	output = kthNonDivisible(N, K)
	lst.append(output)
print(*lst, sep='\n')


def f(x):
	return x - x // n
t = int(input())
ans = [0 for i in range(t)]
for i in range(t):
	(n, k) = map(int, input().split())
	l = 0
	r = 10 ** 18
	m1 = -1
	while r - l > 1:
		m = (l + r + 1) // 2
		if m % n == 0:
			m -= 1
		if f(m) <= k:
			l = m
		else:
			r = m
		if m == m1:
			break
		m1 = m
	ans[i] = l
for i in ans:
	print(i)


from math import gcd, ceil
from collections import defaultdict as dd

def lcm(a, b):
	return a * b // gcd(a, b)

def inin():
	return int(input())

def inar():
	return list(map(int, input().split()))

def ar(element, size):
	return [element for i in range(size)]

def digitsum(num):
	su = 0
	while num:
		su += num % 10
		num //= 10
	return su

def pred(n, k, pointer):
	return pointer - k >= n
for i in range(inin()):
	(n, k) = inar()
	div = (k - 1) // (n - 1)
	print(k + div)


from os import path
import sys, time
from math import ceil, floor, gcd, log, log2, factorial, sqrt
from collections import defaultdict, Counter, OrderedDict, deque
from itertools import combinations, accumulate
from bisect import *
from functools import reduce
from operator import mul
star = lambda x: print(' '.join(map(str, x)))
grid = lambda r: [lint() for i in range(r)]
INF = float('inf')
if path.exists('input.txt'):
	sys.stdin = open('input.txt', 'r')
	sys.stdout = open('output.txt', 'w')
import sys
from sys import stdin, stdout
from collections import *
from math import gcd, floor, ceil

def st():
	return list(stdin.readline().strip())

def inp():
	return int(stdin.readline())

def inlt():
	return list(map(int, stdin.readline().split()))

def invr():
	return map(int, stdin.readline().split())

def solve():
	(n, k) = invr()
	res = k + (k - 1) // (n - 1)
	print(res)
t = 1
t = inp()
for _ in range(t):
	solve()


import collections
import operator
for _ in range(int(input())):
	(n, k) = [int(i) for i in input().split(' ')]
	print(k + (k - 1) // (n - 1))


for _ in range(int(input())):
	X = list(map(int, input().split()))
	Round = X[1] // (X[0] - 1)
	if X[1] % (X[0] - 1) == 0:
		print(X[0] * Round - 1)
	else:
		print(X[0] * Round + X[1] % (X[0] - 1))


for i in range(int(input())):
	(n, k) = list(map(int, input().split()))
	if k < n:
		print(k)
	elif k == n:
		print(k + 1)
	else:
		p = k // (n - 1)
		q = p * n
		if k % (n - 1) == 0:
			print(q - 1)
		else:
			print(q + k % (n - 1))


def main():
	t = int(input())
	for tt in range(t):
		(n, k) = map(int, input().split())
		print(k + (k - 1) // (n - 1))
main()


import sys
T = int(sys.stdin.readline())
for _ in range(T):
	(n, k) = map(int, sys.stdin.readline().split())
	result = (k - 1) // (n - 1) + k
	print(result)


def answer(n, k):
	q = k // (n - 1)
	r = k % (n - 1)
	if r:
		return n * q + r
	else:
		return n * q - 1
t = int(input())
for _ in range(t):
	(n, k) = map(int, input().split())
	print(answer(n, k))


T = int(input())
for i in range(T):
	(N, K) = map(int, input().split())
	if K % (N - 1) == 0:
		print(K // (N - 1) * N - 1)
	else:
		print(K // (N - 1) * N + K % (N - 1))


t = int(input())
for x in range(t):
	(n, k) = map(int, input().split(' '))
	if k < n:
		print(k)
	elif n == k:
		print(k + 1)
	else:
		print(k + (k - 1) // (n - 1))


t = int(input())
for i in range(t):
	(n, k) = map(int, input().split())
	q = 1
	p = 0
	while q != 0:
		q = int(k // n) - p
		p = int(k // n)
		if q == 0:
			break
		k += q
	print(k)


t = int(input())
for _ in range(t):
	(n, k) = [int(x) for x in input().split()]
	b = k
	ans = -1
	while b > 0:
		while ans + b - (ans + b) // n < k:
			ans += b
		b //= 2
	print(ans + 1)


q = int(input())
while q > 0:
	q -= 1
	(n, k) = map(int, input().split())
	l = 0
	r = int(1000000000.0)
	while l <= r:
		mid = (l + r) // 2
		if k - (mid * n - mid) <= 0:
			r = mid - 1
		elif k - (mid * n - mid) < n:
			print(mid * n + (k - (mid * n - mid)))
			break
		else:
			l = mid + 1


def solve(n, k):
	value = 0
	counted = 0
	rem = k
	while rem:
		initial_multiples = value // n
		value += rem
		multiples = value // n
		multiples_added = multiples - initial_multiples
		counted += rem - multiples_added
		rem = k - counted
	return value

def main():
	T = int(input())
	for _ in range(T):
		(n, k) = map(int, input().split())
		print(solve(n, k))
main()


import sys
input = sys.stdin.readline
import bisect
t = int(input())
while t:
	(n, k) = map(int, input().split())
	nn = n - 1
	x = k // nn
	r = k % nn
	if r > 0:
		h = x * n
		h += r
	else:
		h = x * n - 1
	print(h)
	t -= 1


def z(n, k):
	if k < n:
		return k
	else:
		s = k // n
		if (k + s) // n == s:
			return k + s
		else:
			m = s * n
			k = k - s * n + s
			return m + z(n, k)
for _ in range(int(input())):
	(n, k) = map(int, input().split())
	print(z(n, k))


from sys import stdin, stdout
from itertools import combinations
from collections import defaultdict, Counter
import math

def listIn():
	return list(map(int, stdin.readline().strip().split()))

def stringListIn():
	return [x for x in stdin.readline().split()]

def intIn():
	return int(stdin.readline())

def stringIn():
	return stdin.readline().strip()
t = int(input())
while t > 0:
	t -= 1
	(n, k) = listIn()
	start = k // n
	while True:
		num = k + start
		end = num // n
		if end == start:
			break
		else:
			start = end
	print(k + start)


t = int(input())
e = 10 ** 9 + 7
for _ in range(t):
	(n, k) = map(int, input().split())
	ans = k
	m = k // n
	ans += m
	while m != 0:
		m = ans // n - (ans - m) // n
		ans += m
	print(ans)


t = int(input())
for q in range(t):
	(n, k) = map(int, input().split())
	count = 0
	num = 0
	count += (n - 1) * (k // (n - 1))
	num = n * (k // (n - 1)) - 1
	if count < k:
		num += k - count + 1
	print(num)


t = int(input())
ans_list = []
for _ in range(t):
	(n, k) = input().split(' ')
	n = int(n)
	k = int(k)
	rem = k % (n - 1)
	ans = k + k // (n - 1)
	if not rem:
		ans -= 1
	print(ans)


import sys, bisect, string, math, time, functools, random
from heapq import heappush, heappop, heapify
from collections import deque, defaultdict, Counter
from itertools import permutations, combinations, groupby

def Golf():
	(*a,) = map(int, open(0))

def I():
	return int(input())

def S_():
	return input()

def IS():
	return input().split()

def LS():
	return [i for i in input().split()]

def LI():
	return [int(i) for i in input().split()]

def LI_():
	return [int(i) - 1 for i in input().split()]

def NI(n):
	return [int(input()) for i in range(n)]

def NI_(n):
	return [int(input()) - 1 for i in range(n)]

def StoLI():
	return [ord(i) - 97 for i in input()]

def ItoS(n):
	return chr(n + 97)

def LtoS(ls):
	return ''.join([chr(i + 97) for i in ls])

def GI(V, E, ls=None, Directed=False, index=1):
	org_inp = []
	g = [[] for i in range(V)]
	FromStdin = True if ls == None else False
	for i in range(E):
		if FromStdin:
			inp = LI()
			org_inp.append(inp)
		else:
			inp = ls[i]
		if len(inp) == 2:
			(a, b) = inp
			c = 1
		else:
			(a, b, c) = inp
		if index == 1:
			a -= 1
			b -= 1
		aa = (a, c)
		bb = (b, c)
		g[a].append(bb)
		if not Directed:
			g[b].append(aa)
	return (g, org_inp)

def GGI(h, w, search=None, replacement_of_found='.', mp_def={'#': 1, '.': 0}, boundary=1):
	mp = [boundary] * (w + 2)
	found = {}
	for i in range(h):
		s = input()
		for char in search:
			if char in s:
				found[char] = (i + 1) * (w + 2) + s.index(char) + 1
				mp_def[char] = mp_def[replacement_of_found]
		mp += [boundary] + [mp_def[j] for j in s] + [boundary]
	mp += [boundary] * (w + 2)
	return (h + 2, w + 2, mp, found)

def TI(n):
	return GI(n, n - 1)

def bit_combination(k, n=2):
	rt = []
	for tb in range(n ** k):
		s = [tb // n ** bt % n for bt in range(k)]
		rt += [s]
	return rt

def show(*inp, end='\n'):
	if show_flg:
		print(*inp, end=end)
YN = ['YES', 'NO']
Yn = ['Yes', 'No']
mo = 10 ** 9 + 7
inf = float('inf')
FourNb = [(1, 0), (-1, 0), (0, 1), (0, -1)]
EightNb = [(1, 0), (-1, 0), (0, 1), (0, -1), (1, 1), (-1, -1), (1, -1), (-1, 1)]
compas = dict(zip('EWNS', FourNb))
l_alp = string.ascii_lowercase
input = lambda : sys.stdin.readline().rstrip()

class Tree:

	def __init__(self, inp_size=None, init=True):
		self.LCA_init_stat = False
		self.ETtable = []
		if init:
			self.stdin(inp_size)
		return

	def stdin(self, inp_size=None, index=1):
		if inp_size == None:
			self.size = int(input())
		else:
			self.size = inp_size
		(self.edges, _) = GI(self.size, self.size - 1, index=index)
		return

	def listin(self, ls, index=0):
		self.size = len(ls) + 1
		(self.edges, _) = GI(self.size, self.size - 1, ls, index=index)
		return

	def __str__(self):
		return str(self.edges)

	def dfs(self, x, func=lambda prv, nx, dist: prv + dist, root_v=0):
		q = deque()
		q.append(x)
		v = [-1] * self.size
		v[x] = root_v
		while q:
			c = q.pop()
			for (nb, d) in self.edges[c]:
				if v[nb] == -1:
					q.append(nb)
					v[nb] = func(v[c], nb, d)
		return v

	def EulerTour(self, x):
		q = deque()
		q.append(x)
		self.depth = [None] * self.size
		self.depth[x] = 0
		self.ETtable = []
		self.ETdepth = []
		self.ETin = [-1] * self.size
		self.ETout = [-1] * self.size
		cnt = 0
		while q:
			c = q.pop()
			if c < 0:
				ce = ~c
			else:
				ce = c
				for (nb, d) in self.edges[ce]:
					if self.depth[nb] == None:
						q.append(~ce)
						q.append(nb)
						self.depth[nb] = self.depth[ce] + 1
			self.ETtable.append(ce)
			self.ETdepth.append(self.depth[ce])
			if self.ETin[ce] == -1:
				self.ETin[ce] = cnt
			else:
				self.ETout[ce] = cnt
			cnt += 1
		return

	def LCA_init(self, root):
		self.EulerTour(root)
		self.st = SparseTable(self.ETdepth, init_func=min, init_idl=inf)
		self.LCA_init_stat = True
		return

	def LCA(self, root, x, y):
		if self.LCA_init_stat == False:
			self.LCA_init(root)
		(xin, xout) = (self.ETin[x], self.ETout[x])
		(yin, yout) = (self.ETin[y], self.ETout[y])
		a = min(xin, yin)
		b = max(xout, yout, xin, yin)
		id_of_min_dep_in_et = self.st.query_id(a, b + 1)
		return self.ETtable[id_of_min_dep_in_et]

class SparseTable:

	def __init__(self, ls, init_func=min, init_idl=float('inf')):
		self.func = init_func
		self.idl = init_idl
		self.size = len(ls)
		self.N0 = self.size.bit_length()
		self.table = [ls[:]]
		self.index = [list(range(self.size))]
		self.lg = [0] * (self.size + 1)
		for i in range(2, self.size + 1):
			self.lg[i] = self.lg[i >> 1] + 1
		for i in range(self.N0):
			tmp = [self.func(self.table[i][j], self.table[i][min(j + (1 << i), self.size - 1)]) for j in range(self.size)]
			tmp_id = [self.index[i][j] if self.table[i][j] == self.func(self.table[i][j], self.table[i][min(j + (1 << i), self.size - 1)]) else self.index[i][min(j + (1 << i), self.size - 1)] for j in range(self.size)]
			self.table += [tmp]
			self.index += [tmp_id]

	def query(self, l, r):
		r = min(self.size, r)
		N = self.lg[r - l]
		return self.func(self.table[N][l], self.table[N][r - (1 << N)])

	def query_id(self, l, r):
		N = self.lg[r - l]
		(a, b) = (self.index[N][l], self.index[N][r - (1 << N)])
		if self.table[0][a] == self.func(self.table[N][l], self.table[N][r - (1 << N)]):
			b = a
		return b

	def __str__(self):
		return str(self.table[0])

	def print(self):
		for i in self.table:
			print(*i)
show_flg = False
show_flg = True
ans = 0
T = I()
for _ in range(T):
	(n, k) = LI()
	a = k // (n - 1)
	t = (k - a * (n - 1)) % n
	if t == 0:
		t = -1
	ans = a * n + t
	print(ans)


testcases = int(input())
for testcase in range(testcases):
	newarr = input()
	newarr = newarr.split()
	n = int(newarr[0])
	k = int(newarr[1])
	diff = n - 1
	if k <= diff:
		print(k)
		continue
	newdiff = k // diff
	if k % diff == 0:
		ans = n * newdiff - 1
		print(ans)
		continue
	curterm = diff * newdiff
	diffdiff = newdiff * n
	diffterm = k - curterm
	print(diffdiff + diffterm)


def solve(n, k):
	if k % (n - 1) == 0:
		ans = n * (k // (n - 1)) - 1
	else:
		ans = k // (n - 1) * n + k % (n - 1)
	return ans
t = int(input())
for i in range(t):
	input_nums = input().split(' ')
	answer = solve(int(input_nums[0]), int(input_nums[1]))
	print(answer)


from sys import stdin
input = stdin.readline
for ti in range(int(input().strip())):
	(n, k) = [int(x) for x in input().strip().split()]
	print(k // (n - 1) * n + k % (n - 1) - (1 if not k % (n - 1) else 0))


for t in range(int(input())):
	(n, k) = list(map(int, input().split()))
	prk = k // (n - 1)
	mrk = prk * n
	if mrk - prk == k:
		print(mrk - 1)
	else:
		print(mrk + k % (n - 1))


t = int(input())
for tt in range(0, t):
	(n, k) = map(int, input().split())
	need = (k - 1) // (n - 1)
	print(k + need)


import math
t = int(input())
for _ in range(t):
	(n, k) = list(map(int, input().split()))
	vv = math.ceil(k / (n - 1))
	val = k % (n - 1)
	if val == 0:
		val = n - 1
	print(1 + n * (vv - 1) + val - 1)


def ceildiv(a, b):
	return (a + b - 1) // b
for _ in range(int(input())):
	(n, k) = map(int, input().split())
	x = (k - 1) // (n - 1)
	k -= x * (n - 1)
	print(x * n + k)


T = int(input())
for t in range(T):
	tmp = input().split()
	(n, k) = (int(tmp[0]), int(tmp[1]))
	kp = k // (n - 1)
	if k % (n - 1) == 0:
		tp = -1
	else:
		tp = k % (n - 1)
	print(kp * n + tp)


for _ in range(int(input())):
	(N, K) = map(int, input().split())
	if K < N:
		print(K)
		continue
	elif N == 2:
		print(2 * K - 1)
		continue
	(low, high) = (1, 100000000000)
	while low <= high:
		mid = low + (high - low) // 2
		if mid % N == 0:
			mid += 1
		num = mid - mid // N
		if num == K:
			print(mid)
			break
		elif num > K:
			high = mid - 1
		else:
			low = mid + 1


import sys
input = sys.stdin.readline
from collections import *

def judge(x):
	return x - x // n >= k

def binary_search():
	(l, r) = (1, 10 ** 12)
	while l <= r:
		m = (l + r) // 2
		if judge(m):
			r = m - 1
		else:
			l = m + 1
	return l
t = int(input())
for _ in range(t):
	(n, k) = map(int, input().split())
	print(binary_search())


import math
t = int(input())
num = [input().split() for x in range(t)]
for y in num:
	i = 0
	n = int(y[0])
	k = int(y[1])
	need = math.floor((k - 1) / (n - 1))
	ans = k + need
	if ans % n == 0:
		print(ans - 1)
	else:
		print(ans)


t = int(input())
for j in range(t):
	(n, k) = list(map(int, input().split(' ')))
	if k % (n - 1) == 0:
		x = k // (n - 1)
	else:
		x = k // (n - 1) + 1
	count = n * (x - 1) - (x - 1)
	i = n * (x - 1) + (k - count)
	print(i)


for t in range(int(input())):
	(n, k) = map(int, input().split())
	x = n * k
	x //= n - 1
	if not x % n:
		x -= 1
	print(x)


t = int(input())
for _ in range(t):
	(n, k) = map(int, input().split())
	i = k // (n - 1) + 1
	start = n * i - 1
	count = n * i - i
	diff = count - k
	if diff < n - 1:
		print(start - diff)
	else:
		print(start - diff - 1)


import math as mt
import sys, string
input = sys.stdin.readline
import random
from collections import deque, defaultdict
L = lambda : list(map(int, input().split()))
Ls = lambda : list(input().split())
M = lambda : map(int, input().split())
I = lambda : int(input())
t = I()
for i in range(t):
	(n, k) = M()
	if k < n:
		print(k)
	else:
		w = n * ((k - 1) // (n - 1))
		if k % (n - 1) == 0:
			w += n - 1
		else:
			w += k % (n - 1)
		print(w)


def read_int():
	return int(input())

def read_ints():
	return map(int, input().split(' '))
t = read_int()
for case_num in range(t):
	(n, k) = read_ints()
	loops = k // (n - 1)
	if k % (n - 1) == 0:
		print(loops * n - 1)
	else:
		print(loops * n + k % (n - 1))


import math
for _ in range(int(input())):
	(n, k) = map(int, input().split())
	if n > k:
		print(k)
	else:
		new = 0
		d = 0
		s = k
		while True:
			di = s // n
			new = s + di - d
			d = new // n - di
			if d == 0:
				break
			s = new
			d = di
		print(new)


nb = int(input())
for loop in range(nb):
	(n, k) = map(int, input().split())
	r = (k - 1) // (n - 1)
	print(k + r)


T = int(input())
for i in range(T):
	(n, k) = map(int, input().split())
	N = n - 1
	x = k // N
	rem = k % N
	if rem == 0:
		ans = x * n - 1
	else:
		ans = x * n + rem
	print(ans)


import sys

def func(x):
	x = x.split()
	if len(x) == 1:
		return int(x[0])
	x = [int(each) for each in x]
	return x
inputs = []
for line in sys.stdin:
	inputs += [line.split('\n')[0].strip()]
inputs = [func(each) for each in inputs]
for i in range(inputs[0]):
	(n, k) = (inputs[i + 1][0], inputs[i + 1][1])
	low = 1
	high = n * k
	while low <= high:
		mid = low + (high - low) // 2
		quotient = mid // n
		remaining_elem = mid - quotient
		if remaining_elem > k:
			high = mid - 1
		elif remaining_elem < k:
			low = mid + 1
		else:
			print(mid - (mid % n == 0))
			break


import math

def kth(n, m):
	result = m + math.ceil(m / (n - 1)) - 1
	return result
n = int(input())
for i in range(n):
	line1 = map(lambda x: int(x), input().strip().split())
	print(kth(*line1))


t = int(input())
l = []

def nNo(l):
	n = l[0]
	k = l[1]
	if k % (n - 1) != 0:
		res = n * (k // (n - 1)) + k % (n - 1)
	else:
		res = n * (k / (n - 1)) - 1
	print(int(res))
for i in range(t):
	l.append(list(map(int, input().split(' '))))
for i in range(t):
	nNo(l[i])


import math
t = int(input())
for _ in range(t):
	(n, k) = map(int, input().split())
	if n > k:
		print(k)
	else:
		remain = k - (n - 1)
		idx = math.ceil(remain / (n - 1))
		ans = 1 + n * idx
		ans += (remain - 1) % (n - 1)
		print(ans)


t = int(input())
while t > 0:
	t -= 1
	(n, k) = list(map(int, input().split(' ')))
	if n > k:
		print(k)
		continue
	initial = n - 1
	copy = n
	diff = k - initial
	multiplier = diff // initial
	if diff % initial != 0:
		multiplier += 1
	initial = initial + initial * multiplier
	copy = copy + copy * multiplier
	copy = copy - 1
	print(copy - (initial - k))


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


from math import *
for zz in range(int(input())):
	(n, k) = map(int, input().split())
	t = k // (n - 1)
	ans = t * n + k - t * (n - 1)
	if ans % n == 0:
		ans -= 1
	print(ans)


def solve(n, k):
	jmp = k // (n - 1)
	(eles, val) = (jmp * (n - 1), jmp * n)
	if k < eles:
		print(val - (eles - k))
	elif k == eles:
		print(val - 1)
	else:
		print(val + (k - eles))
for _ in range(int(input())):
	(n, k) = map(int, input().split())
	solve(n, k)


for _ in range(int(input())):
	(a, b) = map(int, input().split())
	t = a - 1
	b1 = b % t
	b2 = b // t
	k = a * b2 + b1
	if k % a == 0:
		k -= 1
	print(k)


from math import floor, ceil

def main():
	t = int(input())
	for i in range(t):
		nk = input().split()
		n = int(nk[0])
		k = int(nk[1])
		numSets = k / (n - 1)
		print(ceil(numSets * n - 1))
main()


import sys
input = sys.stdin.readline
for i in range(int(input())):
	(n, k) = [int(c) for c in input().split()]
	e = k % (n - 1)
	k = k // (n - 1) * n
	if k % n == 0:
		if e > 0:
			k += e
		else:
			k -= 1
	print(k)


for i in range(int(input())):
	(n, k) = map(int, input().split())
	num = k // (n - 1)
	passed = num * (n - 1)
	k -= passed
	print(n * num + k - 1 if k == 0 else n * num + k)


n = int(input())
for i in range(n):
	(p, q) = map(int, input().split())
	if p <= q:
		if q % (p - 1) == 0:
			print(q // (p - 1) * p - 1)
		else:
			print(q // (p - 1) * p + q % (p - 1))
	else:
		print(q)


for _ in range(int(input())):
	(n, k) = map(int, input().split())
	(l, r, x) = (0, int(2000000000.0), 0)
	while l <= r:
		m = l + r >> 1
		if m * (n - 1) < k:
			x = m * n
			l = m + 1
		else:
			r = m - 1
	print(x + k % (n - 1) + (n - 1) * (k % (n - 1) == 0))


t = int(input())
while t > 0:
	(n, k) = [int(ele) for ele in input().split()]
	div = k // n
	prev_d = div
	while div != 0:
		k += div
		d = k // n
		div = d - prev_d
		prev_d = d
	print(k)
	t -= 1


t = int(input())
for tt in range(t):
	(n, k) = map(int, input().split())
	if k < n:
		print(k)
	else:
		ans = k + (k - 1) // (n - 1)
		print(ans)


import sys
import math
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
mod = 1000000007

def nospace(l):
	ans = ''.join((str(i) for i in l))
	return ans
t = int(input())
for tt in range(t):
	(n, k) = map(int, sys.stdin.readline().split(' '))
	r = k // (n - 1)
	v = n * r
	d = k % (n - 1)
	ans = v + d
	if d == 0:
		ans -= 1
	print(ans)
if fileoperation:
	sys.stdout = orig_stdout
	sys.stdin = orig_stdin
	inputfile.close()
	outputfile.close()


t = int(input())
for j in range(t):
	(n, k) = [int(x) for x in input().split()]
	aux = k // n
	b = k - aux * n
	aux += b
	temp = aux
	while temp // n > 0:
		resto = 0
		resto += temp % n
		temp = temp // n
		aux += temp
		temp += resto
	resp = k // n * n + aux
	if resp % n == 0:
		resp += 1
	print(resp)


import sys, collections
import io, os
import math
for _ in range(int(input())):
	(n, k) = map(int, input().split())
	q = k // n
	req = q + k
	while req // n > q:
		prev = q
		q = req // n
		req += q - prev
	print(req)


t = int(input())
for _ in range(t):
	(n, k) = map(int, input().split(' '))
	low = 1
	high = 10 ** 21
	ans = -1
	while low <= high:
		mid = (low + high) // 2
		if mid - mid // n >= k:
			high = mid - 1
			ans = mid
		elif mid - mid // n < k:
			low = mid + 1
	print(ans)


t = int(input())
while t:
	(n, k) = map(int, input().split())
	r = n * k
	l = 1
	while l < r:
		m = (l + r) // 2
		if m - m // n >= k:
			r = m
		else:
			l = m + 1
	print(l)
	t -= 1


def bs(n, k):
	L = 1
	R = 10 ** 18
	while R - L > 5:
		M = (L + R) // 2
		if M - M // n >= k:
			R = M
		else:
			L = M
	for ans in range(L, R + 1):
		if ans % n != 0 and ans - ans // n == k:
			return ans
	return -1
for t in range(int(input())):
	(n, k) = map(int, input().split())
	print(bs(n, k))


for i in range(int(input())):
	(n, k) = map(int, input().split())
	b = 1
	l = []
	s = k
	while True:
		s = s / n
		l.append(s)
		if s < 1:
			break
	print(int(k + sum(l)))


t = int(input())
for _ in range(t):
	(n, k) = map(int, input().split())
	low = 1
	high = int(10 ** 18)
	while low != high:
		mid = (low + high + 1) // 2
		if mid - mid // n > k:
			high = mid - 1
		else:
			low = mid
	assert low - low // n == k
	if low % n == 0:
		low -= 1
	print(low)


def check(m, n):
	return m - m // n
for _ in range(int(input())):
	(n, k) = map(int, input().split())
	(l, r) = (1, 10 ** 10)
	while l <= r:
		m = l + r >> 1
		if check(m, n) >= k:
			r = m - 1
			ans = m
		else:
			l = m + 1
	print(ans)


a = int(input())
for k in range(a):
	b = input().split()
	d = int(b[0])
	e = int(b[1])
	x = d - 1
	z = e // x
	y = e % x
	if y == 0:
		y = -1
	print(z * d + y)


from sys import stdin

def solve(n, k):
	p = 0
	while n // k - p > 0:
		h = n // k - p
		p = n // k
		n = n + h
	print(n)
	return

def main():
	inp = stdin.readline
	for _ in range(int(inp())):
		(k, n) = map(int, inp().split())
		solve(n, k)
main()


import math

def kthNonDivisible(N, K):
	return K + math.floor((K - 1) / (N - 1))
t = int(input())
for _ in range(t):
	(n, k) = [int(x) for x in input().split()]
	print(kthNonDivisible(n, k))


tc = int(input())
while tc > 0:
	(n, k) = map(int, input().split())
	if n > k:
		print(k)
	else:
		(q, r) = divmod(k, n - 1)
		p = q * n
		print(p - 1 if r == 0 else p + r)
	tc -= 1


t = int(input())
out = []
for i in range(t):
	num = [int(a) for a in input().split(' ')]
	n = num[0]
	k = num[1]
	div = int(k / (n - 1))
	mo = int(k % (n - 1))
	if mo == 0:
		ans = n * div - 1
	else:
		ans = n * div + mo
	out.append(ans)
for x in out:
	print(x)


def main():
	queries = int(input())
	for q in range(queries):
		(first, second) = list(map(int, str(input()).split(' ')))
		count = 0
		while True:
			buff = int(second / first - count)
			if not buff:
				break
			second += buff
			count += buff
		print(second)
main()


def ab():
	(b, c) = map(int, input().split())
	e = c // (b - 1)
	e = e * b
	z = c % (b - 1)
	if z == 0:
		print(e - 1)
	else:
		print(e + z)
for i in range(0, int(input())):
	ab()


import math
t = int(input())
for i in range(t):
	ans = 0
	(n, k) = [int(x) for x in input().split()]
	if k > n:
		l = math.floor(k / (n - 1)) * n
		ans = (n - 1) * math.floor(k / (n - 1))
		f = k - ans
		if f == 0:
			ans = l - 1
		else:
			ans = l + f
		print(ans)
	elif n == k:
		print(k + 1)
	else:
		print(k)


def solve():
	(n, k) = [int(i) for i in input().split()]
	l = 1
	r = 10 ** 10
	while l + 1 < r:
		m = (l + r) // 2
		if m - (m - 1) // n <= k:
			l = m
		else:
			r = m
	print(l)
t = int(input())
for i in range(t):
	solve()


def solve(n, k):
	(a, b) = divmod(k, n - 1)
	if b == 0:
		b = -1
	print(n * a + b)
t = 1
t = int(input())
while t > 0:
	(n, k) = [int(x) for x in input().split()]
	solve(n, k)
	t -= 1


from sys import stdin

def main():
	readline = stdin.readline
	t = int(readline())
	res = []
	for i in range(t):
		(n, k) = map(int, readline().split())
		l = 0
		r = 3 * 10 ** 9
		cnt = 0
		while True:
			x = (l + r) // 2
			if x % n == 0:
				x += 1
			y = x // n
			if x - y < k:
				l = x
			elif x - y > k:
				r = x
			elif x - y == k:
				res.append(x)
				break
	for i in range(t):
		print(res[i])
main()


testcases = int(input())
while testcases > 0:
	testcases = testcases - 1
	(n, k) = map(int, input().split())
	need = n - 1 // k - 1
	print(k + (k - 1) // (n - 1))


import math
import collections
from sys import stdin, stdout, setrecursionlimit
from bisect import bisect_left as bsl
from bisect import bisect_right as bsr
import heapq as hq
setrecursionlimit(2 ** 20)
t = 1
t = int(stdin.readline())
for _ in range(t):
	(n, k) = list(map(int, stdin.readline().rstrip().split()))
	lam = k // (n - 1)
	till_now = lam * (n - 1)
	ans = lam * n
	if k % (n - 1) == 0:
		ans -= 1
	print(ans + (k - till_now))


for _ in range(int(input())):
	(n, k) = map(int, input().split())
	temp = k // n
	temp1 = temp + k
	while True:
		if temp1 // n - temp != 0:
			extra = temp1 // n - temp
			temp += extra
			temp1 = temp + k
		else:
			break
	print(k + temp)


for _ in range(int(input())):
	(n, k) = map(int, input().split())
	if k < n:
		print(k)
		continue
	if k == n:
		print(n + 1)
		continue
	k1 = k // (n - 1)
	g = n * k1
	g1 = g + k % (n - 1)
	if g1 % n != 0:
		print(g1)
	else:
		print(g - 1)


import math
r1 = lambda : int(input())
rm = lambda : map(int, input().split())
rls = lambda : list(rm())
test = r1()
while test:
	test -= 1
	(n, k) = rm()
	x = k // (n - 1) * n
	if k % (n - 1) == 0:
		x -= 1
	else:
		x += k % (n - 1)
	print(x)


t = int(input())
for _ in range(t):
	(n, k) = [int(s) for s in input().split(' ')]
	t = (k - 1) // (n - 1)
	s = (k - 1) % (n - 1)
	print(t * n + s + 1)


def func(n, k):
	need = (k - 1) // (n - 1)
	return k + need
testcase = int(input())
for i in range(testcase):
	(n, k) = map(int, input().rstrip().split())
	print(func(n, k))


import math
mxn = 10 ** 9 + 11
for ii in range(int(input())):
	(n, k) = map(int, input().split())
	l = 0
	r = 10 ** 18
	while l <= r:
		mid = l + (r - l) // 2
		actcount = mid - mid // n
		if actcount == k:
			break
		if actcount < k:
			l = mid
		if actcount > k:
			r = mid
	print(mid if mid % n != 0 else mid - 1)


for testcase in range(int(input())):
	(n, k) = map(int, input().split())
	k -= 1
	ans = 0
	for bit in range(30, -1, -1):
		take = (n - 1) * (1 << bit)
		if k >= take:
			k -= take
			ans += n * (1 << bit)
	print(ans + k + 1)


import math

def r():
	return map(int, input().split())

def l():
	return list(map(int, input().split()))

def i():
	return int(input())

def si():
	return input()

def pYes():
	print('YES')

def pNo():
	print('NO')

def plist(l):
	print(''.join(l))
t = int(input())
for i in range(t):
	(n, k) = map(int, input().split())
	r = k // (n - 1)
	q = k % (n - 1)
	e = n * r
	if q == 0:
		q = q - 1
	print(e + q)


def kth_not_div_n(n, k):
	num_blocks = k // (n - 1)
	residue = k % (n - 1)
	print(num_blocks * n + residue - int(residue == 0))
t = int(input())
for _ in range(t):
	(n, k) = [int(i) for i in input().split()]
	kth_not_div_n(n, k)


t = int(input())
while t:
	t -= 1
	a = list(map(int, input().strip().split()))[0:2]
	x = a[0]
	y = a[1]
	z = y // (x - 1)
	ans = x * z
	if y % (x - 1) == 0:
		ans -= 1
	else:
		ans += y % (x - 1)
	print(ans)


import sys
fast_reader = sys.stdin.readline
fast_writer = sys.stdout.write

def input():
	return fast_reader().strip()

def print(*argv):
	fast_writer(' '.join((str(i) for i in argv)))
	fast_writer('\n')

def list_input():
	return list(map(int, input().split()))

def sep_input():
	return map(int, input().split())
for _ in range(int(input())):
	(a, b) = sep_input()
	print(b + (b - 1) // (a - 1))


t = int(input())
for i in range(t):
	(n, k) = map(int, input().split())
	q = k // (n - 1)
	resto = k % (n - 1)
	num = q * n + resto
	if resto == 0:
		num -= 1
	print(num)


import sys
input = sys.stdin.readline
t = int(input())
for _ in range(t):
	(n, k) = map(int, input().rstrip().split())
	i = n - 1
	x = k // i
	y = k % i
	if y == 0:
		y = -1
	res = n * x + y
	print(res)


t = int(input())
for _ in range(t):
	nk = input().split()
	n = int(nk[0])
	k = int(nk[1])
	print(k + (k - 1) // (n - 1))


t = int(input())
elem = []
res = []
for i in range(t):
	elem.append(list(map(int, input().split())))
for (n, k) in elem:
	m = n - 1
	(s, o) = (k // m, k % m)
	if k % (n - 1) != 0:
		res = s * n + o
	else:
		res = s * n - 1
	print(res)


t = int(input())
for i in range(t):
	(n, k) = map(int, input().split())
	left = 0
	right = 10 ** 18
	ans = 0
	while left <= right:
		mid = left + (right - left) // 2
		nseg = mid // n
		dk = (n - 1) * nseg + (mid - nseg * n)
		if dk == k:
			ans = mid
		if dk >= k:
			right = mid - 1
		else:
			left = mid + 1
	print(ans)


t = int(input())
while t > 0:
	(n, k) = map(int, input().split())
	l = 1
	r = 2 * k
	ans = -1
	while l <= r:
		mid = l + r >> 1
		cnt = mid // n
		not_divisible = mid - cnt
		if not_divisible < k:
			l = mid + 1
		elif not_divisible == k:
			ans = mid
			r = mid - 1
		else:
			r = mid - 1
	print(ans)
	t -= 1


import sys
input = lambda : sys.stdin.readline().rstrip()
inp = sys.stdin.buffer.readline
from math import ceil

def I():
	return list(map(int, inp().split()))
for _ in range(I()[0]):
	(n, k) = I()
	ans = k // (n - 1) * n
	if k % (n - 1) == 0:
		ans -= 1
	else:
		ans += k % (n - 1)
	print(ans)


n = int(input())
for i in range(n):
	(k, g) = [int(el) for el in input().split()]
	print(g // (k - 1) * k + g % (k - 1) - (g % (k - 1) == 0))


for i in range(int(input())):
	(n, k) = map(int, input().split())
	d = k // (n - 1)
	r = k % (n - 1)
	if r == 0:
		r = -1
	ans = n * d + r
	print(ans)


t = int(input())
for case in range(t):
	(n, k) = list(map(int, input().split()))
	ans = n * ((k - 1) // (n - 1)) + k % (n - 1)
	if k % (n - 1) == 0:
		ans += n - 1
	print(ans)


for i in range(int(input())):
	(n, m) = map(int, input().split())
	var = m // (n - 1)
	va = var * n
	rem = m % (n - 1)
	if rem == 0:
		ans = va - 1
	else:
		ans = va + rem
	print(ans)


import math
n = int(input())
q = []
for i in range(n):
	q.append(input())
for i in q:
	ss = i.split(' ')
	n = int(ss[0])
	k = int(ss[1])
	z = math.ceil(k / (n - 1))
	y = (z - 1) * n
	done = y - math.floor(y / n)
	left = k - done
	print(y + left)


for i in range(int(input())):
	(n, m) = map(int, input().split())
	print(m + (m - 1) // (n - 1))


import sys
input = sys.stdin.readline
t = int(input())
for r in range(t):
	(n, k) = map(int, input().split())
	if n > k:
		print(k)
	elif k == n:
		print(k + 1)
	elif k % (n - 1) == 0:
		x = k // (n - 1)
		print(x * n - 1)
	else:
		x = k // (n - 1)
		a = k % (n - 1)
		print(x * n + a)


def ip():
	return int(input())

def Ip():
	return map(int, input().split())
for _ in range(0, int(input())):
	(n, k) = Ip()
	x = n * (k // (n - 1) - (k % (n - 1) == 0))
	nd = x - x // n
	print(x + k - nd)


def fun(n, k, min, max):
	t = (k - 1) // (n - 1)
	print(t + k)
for _ in range(int(input())):
	(n, k) = map(int, input().split())
	fun(n, k, 0, 1000000000)


for p in range(int(input())):
	(n, k) = input().split(' ')
	n = int(n)
	k = int(k)
	div = k // (n - 1)
	rem = k % (n - 1)
	if rem == 0:
		print(n * div + -1)
	else:
		print(n * div + rem)


for _ in range(int(input())):
	(n, k) = map(int, input().split())
	f = k // n
	while (k + f) // n != f:
		f = (k + f) // n
	print(k + f)


t = int(input())
for tt in range(t):
	(n, k) = map(int, input().split())
	res = k
	x = 0
	while res // n > x:
		x = res // n
		res = k + x
	print(res)


import math
t = int(input())
for i in range(0, t):
	(n, k) = list(map(int, input().split()))
	print(k + int((k - 1) / (n - 1)))


import sys
ints = (int(x) for x in sys.stdin.read().split())
sys.setrecursionlimit(3000)

def main():
	ntc = next(ints)
	for tc in range(ntc):
		(n, k) = (next(ints) for i in range(2))
		(q, r) = divmod(k, n - 1)
		ans = q * n + r if r > 0 else q * n - 1
		print(ans)
	return
main()


n = int(input())
while n:
	(a, b) = map(int, input().split())
	shift = (b - 1) // (a - 1)
	print(b + shift)
	n -= 1


def solve():
	(n, k) = map(int, input().split())
	if k < n:
		print(k)
	else:
		x = k // (n - 1)
		y = x * (n - 1)
		c = k - y
		if c == 0:
			print(n * x - 1)
		else:
			print(c + n * x)
try:
	for _ in range(int(input())):
		solve()
except:
	pass


t = int(input())
for _ in range(t):
	(n, k) = [int(i) for i in input().split()]
	ans = k + (k - 1) // (n - 1)
	print(ans)


from math import *
from copy import *
from string import *
from random import *
from sys import stdin
from sys import maxsize
from operator import *
from itertools import *
from collections import Counter
import math
import math

def bin1(l, r, k, t, b, val, ans):
	if l > r:
		return ans
	else:
		mid = (l + r) // 2
		v = k ** mid
		if v == val:
			return v
		elif v > val:
			ans = mid
			return bin1(mid + 1, r, k, t, b, val, ans)
		else:
			return bin1(l, mid - 1, k, t, b, val, ans)

def bin2(l, r, k, t, b, val, ans):
	if l > r:
		return ans
	else:
		mid = (l + r) // 2
		v = t * k ** mid + b * mid
		if v == val:
			return v
		elif v > val:
			ans = mid
			return bin2(l, mid - 1, k, t, b, val, ans)
		else:
			return bin2(mid + 1, r, k, t, b, val, ans)

def SieveOfEratosthenes(n):
	prime = [True for i in range(n + 1)]
	p = 2
	while p * p <= n:
		if prime[p] == True:
			for i in range(p * p, n + 1, p):
				prime[i] = False
		p += 1
	l = []
	for i in range(2, n + 1):
		if prime[i]:
			l.append(i)
	return l

def bin(l, r, ll, val):
	if l > r:
		return -1
	else:
		mid = (l + r) // 2
		if val >= ll[mid][0] and val <= ll[mid][1]:
			return mid
		elif val < ll[mid][0]:
			return bin(l, mid - 1, ll, val)
		else:
			return bin(mid + 1, r, ll, val)

def deci(n):
	s = ''
	while n != 0:
		if n % 2 == 0:
			n = n // 2
			s = '0' + s
		else:
			n = n // 2
			s = '1' + s
	return s

def diff(s1, s2):
	if len(s1) < len(s2):
		v = len(s1)
		while v != len(s2):
			s1 = '0' + s1
			v = v + 1
	else:
		v = len(s2)
		while v != len(s1):
			s2 = '0' + s2
			v = v + 1
	c = 0
	for i in range(len(s1)):
		if s1[i:i + 1] != s2[i:i + 1]:
			c = c + 1
	return c
from sys import stdin, stdout

def fac(a, b):
	v = a
	while a != b:
		v *= a - 1
		a = a - 1
	return v

def bino(l, r, n):
	if l > r:
		return -1
	else:
		mid = (l + r) // 2
		val1 = math.log(n / mid + 1, 2)
		val2 = int(val1)
		if val1 == val2:
			return val1
		elif val1 < 1.0:
			return bino(l, mid - 1, n)
		else:
			return bino(mid + 1, r, n)

def binary(l, r, val, ans):
	if l > r:
		return -1
	else:
		mid = (l + r) // 2
		v = val ** 5 - mid ** 5
		print(v)
		if v == ans:
			print('HOHOHOH')
			return mid
		elif v < ans:
			return binary(mid + 1, r, val, ans)
		else:
			return binary(l, mid - 1, val, ans)

def check(n):
	v = 1
	while n != 0:
		if n % 10 == 0 or n % 10 == 1:
			n = n // 10
		else:
			v = 0
			break
	return v

def stairs(n, m, val, c, l):
	if val > n:
		return 100000
	elif val == n:
		if l[val] != -1:
			return l[val]
		elif c % m == 0:
			l[val] = c
			return l[val]
		else:
			l[val] = 100000
			return l[val]
	else:
		l[val] = min(stairs(n, m, val + 1, c + 1, l), stairs(n, m, val + 2, c + 1, l))
		return l[val]

def fact(n):
	if n == 0 or n == 1:
		return 1
	else:
		return n * fact(n - 1)

def some(n):
	s = 0
	while n != 0:
		s += fact(n % 10)
		n //= 10
	return s

def bin(l, r, val, ll):
	if l > r:
		return -1
	else:
		mid = (l + r) // 2
		print(ll[mid])
		if ll[mid] == val:
			return mid
		elif ll[mid] > val:
			return bin(l, mid - 1, val, ll)
		else:
			return bin(mid + 1, r, val, ll)
t = int(input())
for i in range(t):
	(n, k) = map(int, input().split())
	if k < n:
		print(k)
	elif k == n:
		print(n + 1)
	elif k % (n - 1) == 0:
		val = k // (n - 1)
		v = k % (n - 1)
		print(n * val + v - 1)
	else:
		val = k // (n - 1)
		v = k % (n - 1)
		print(n * val + v)


q = int(input())
for i in range(q):
	(n, k) = map(int, input().split())
	d = k // (n - 1)
	if k % (n - 1) == 0:
		print(d * n - 1)
	else:
		print(n * d + k % (n - 1))


t = int(input())
for t in range(0, t):
	q = list(map(int, input().rstrip().split()))
	n = q[0]
	k = q[1]
	c = 0
	gap = n - 1
	ans = 0
	if k % gap == 0:
		c = k // gap
		ans = n * c - 1
		print(ans)
	else:
		c = k // gap
		r = k % gap
		ans = n * c + r
		print(ans)


t = int(input())
for loop in range(t):
	(n, k) = map(int, input().split())
	x = k // (n - 1)
	rem = k % (n - 1)
	ans = x * n + rem
	if ans % n == 0:
		ans -= 1
	print(ans)


t = int(input())
for i in range(t):
	(n, k) = list(map(int, input().split()))
	div = n - 1
	(a, b) = divmod(k, div)
	if b == 0:
		b -= 1
	ans = n * a + b
	print(ans)


t = int(input())
for _ in range(t):
	(n, k) = list(map(int, input().split()))
	if k < n:
		print(k)
	elif k == n:
		print(k + 1)
	elif n == 2:
		x = (k - 1) * 2
		print(x + 1)
	elif k % (n - 1) == 0:
		x = k // (n - 1)
		y = x * n
		z = y - 1
		print(z)
	else:
		x = k // (n - 1)
		y = x * n
		z = y + k - x * (n - 1)
		print(z)


import sys
t = int(sys.stdin.readline().strip())
for i in range(0, t):
	(n, k) = list(map(int, sys.stdin.readline().strip().split()))
	d = (k - 1) // (n - 1)
	r = (k - 1) % (n - 1) + 1
	print(d * n + r)


numbers_count = int(input())
numbers = [input() for i in range(0, numbers_count)]
for number in numbers:
	(n, k) = (int(n) for n in number.split(' '))
	if k < n:
		print(k)
		continue
	else:
		print(f'{k + (k - 1) // (n - 1)}')


t = int(input())
for _ in range(t):
	(n, k) = input().split(' ')
	n = int(n)
	k = int(k)
	pre = k
	b = pre // n
	a = 0
	while 1:
		nex = pre
		nex += b - a
		a = pre // n
		b = nex // n
		if a == b:
			print(nex)
			break
		else:
			pre = nex


t = int(input())
AnsList = []
for _ in range(t):
	(n, k) = map(int, input().split())
	q = k // (n - 1)
	r = k % (n - 1)
	if r == 0:
		ans = q * n - 1
	else:
		ans = q * n + r
	AnsList.append(ans)
for x in AnsList:
	print(x)


import math

def solve_test_case():
	INPUT = input().split()
	n = int(INPUT[0])
	k = int(INPUT[1])
	low = 0
	high = 10000000000
	while low < high:
		mid = math.floor((low + high) / 2)
		number = mid - math.floor(mid / n)
		if number >= k:
			high = mid
		else:
			low = mid + 1
	print(low)

def main():
	t = int(input())
	for i in range(t):
		solve_test_case()
main()


t = int(input())
for i in range(t):
	(n, k) = map(int, input().split())
	one = n - 1
	full = k // one
	if k % one == 0:
		print(n * full - 1)
	else:
		print(n * full + k % one)


for test in range(int(input())):
	(n, k) = map(int, input().split())
	y = k % (n - 1)
	x = k // (n - 1)
	ans = x * n
	if y == 0:
		ans = ans - 1
	else:
		ans += y
	print(ans)


import sys
readline = sys.stdin.readline
readlines = sys.stdin.readlines
ns = lambda : readline().rstrip()
ni = lambda : int(readline().rstrip())
nm = lambda : map(int, readline().split())
nl = lambda : list(map(int, readline().split()))
prn = lambda x: print(*x, sep='\n')

def solve():
	(n, k) = nm()
	if k % (n - 1) == 0:
		print(n * (k // (n - 1)) - 1)
	else:
		print(n * (k // (n - 1)) + k % (n - 1))
T = ni()
for _ in range(T):
	solve()


t = int(input())
res = []
for i in range(t):
	inp = input().split()
	n = int(inp[0])
	k = int(inp[1])
	if k < n:
		res.append(k)
	else:
		x = k * n / (n - 1)
		if x % n == 0:
			res.append(x - 1)
		else:
			res.append(x)
for i in res:
	print(int(i))


t = int(input())
lst0 = []
for i in range(t):
	(n, k) = input().split()
	n = int(n)
	k = int(k)
	lst0.append(k + (k - 1) // (n - 1))
for i in range(len(lst0)):
	print(int(lst0[i]))


import sys
input = sys.stdin.readline

def solve(n, k):
	c = k // (n - 1)
	rem = k - c * (n - 1)
	res = c * n - 1
	if rem > 0:
		res += rem + 1
	return res
t = int(input())
for _ in range(t):
	[n, k] = map(int, input().split())
	print(solve(n, k))


tcase = int(input())
6
inputData = [0] * tcase
i = 0
while i < tcase:
	inputData[i] = list(map(int, input().strip().split()))
	i += 1
for x in inputData:
	setnumber = x[1] // (x[0] - 1)
	rem = x[1] % (x[0] - 1)
	sol = setnumber * x[0] + rem
	if rem == 0:
		sol -= 1
	print(sol)


for _ in range(int(input())):
	(a, b) = map(int, input().split())
	(x, z) = (b, 0)
	while b >= a:
		z += b // a
		b = b // a + b % a
	print(x + z)


t = int(input())
for tt in range(t):
	(n, k) = map(int, input().split())
	r1 = (k - 1) // (n - 1)
	print(r1 + k)


t = int(input())
for _ in range(t):
	(n, k) = map(int, input().split())
	ans = k
	if k < n:
		print(k)
	else:
		while k >= n:
			ans += k // n
			k = k // n + k % n
		print(ans)


n_tc = int(input())

def notDivible(n, k):
	if k <= 1:
		return 1
	index = k // (n - 1)
	res = n * index - index
	if k % (n - 1) == 0:
		return n * index + (k - res) - 1
	else:
		return n * index + (k - res)
for i in range(n_tc):
	test_case = input().split()
	n = int(test_case[0])
	k = int(test_case[1])
	print(notDivible(n, k))


t = int(input())
for _ in range(t):
	(a, b) = map(int, input().split(' '))
	temp = b
	while temp != int(temp / a) + b:
		temp = int(temp / a) + b
	print(temp)


import sys
import bisect
import heapq
from math import *
from collections import Counter as counter
from itertools import combinations as comb
from itertools import permutations as permutate
from bisect import bisect_left as bl
from bisect import bisect_right as br
from bisect import bisect
mod = pow(10, 9) + 7

def inp():
	return sys.stdin.readline().strip()

def out(var):
	sys.stdout.write(str(var))

def lis():
	return list(map(int, inp().split()))

def stringlis():
	return list(map(str, inp().split()))

def sep():
	return map(int, inp().split())

def strsep():
	return map(str, inp().split())

def graph(vertex):
	return [[] for i in range(0, vertex + 1)]

def zerolist(n):
	return [0] * n

def nextline():
	out('\n')

def testcase(t):
	for p in range(t):
		solve()

def printlist(a):
	for p in range(0, len(a)):
		out(str(a[p]) + ' ')

def lcm(a, b):
	return a * b // gcd(a, b)

def dfs(v, visited, st, new):
	new.append(st)
	visited[st] = 1
	for i in v[st]:
		if visited[i] == 0:
			dfs(v, visited, i, new)

def solve():
	(n, k) = sep()
	if k % (n - 1) == 0:
		print(n * (k // (n - 1)) - 1)
	else:
		temp = k // (n - 1)
		print(n * temp + (k - (n - 1) * temp))
testcase(int(inp()))


for _ in range(int(input())):
	(n, k) = [int(__) for __ in input().split()]
	if k % (n - 1) != 0:
		print(k // (n - 1) * n + k % (n - 1))
	else:
		print(k // (n - 1) * n - 1)


from math import ceil
t = int(input())
for i in range(t):
	(n, k) = map(int, input().split())
	temp = ceil(k / (n - 1))
	y = temp * n - temp
	ans = temp * n - 1
	x = y - k
	print(ans - x)


import math
a = int(input())
for j in range(0, a):
	ar = []
	for i in input().split(' '):
		ar.append(int(i))
	temp = ar[1] // (ar[0] - 1)
	temp = temp * ar[0] + ar[1] % (ar[0] - 1)
	if temp % ar[0] == 0:
		print(temp - 1)
	else:
		print(temp)


num_cases = int(input())
for _ in range(num_cases):
	(n, k) = tuple([int(x) for x in input().split(' ')])
	print(k + (k - 1) // (n - 1))


for _ in range(int(input())):
	(n, k) = map(int, input().split())
	t1 = n - 1
	t2 = k // t1
	t3 = k % t1
	t4 = t2 * n
	if t3 == 0:
		print(t4 - 1)
	else:
		print(t4 + t3)


def kth(n, k):
	current = k
	answer = current - k // n
	while answer != k:
		current = k + current // n
		answer = current - current // n
	return current
t = int(input())
array = []
for x in range(t):
	array.append(list(map(int, input().split(' '))))
for a in array:
	print(kth(*a))


from __future__ import division, print_function
import os, sys
from io import BytesIO, IOBase
if sys.version_info[0] < 3:
	from __builtin__ import xrange as range
	from future_builtins import ascii, filter, hex, map, oct, zip

def ii():
	return int(input())

def si():
	return input()

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

def li():
	return list(mi())

def read():
	sys.stdin = open('input.txt', 'r')
	sys.stdout = open('output.txt', 'w')

def gcd(x, y):
	while y:
		(x, y) = (y, x % y)
	return x
mod = 1000000007
import math
import bisect
abc = 'abcdefghijklmnopqrstuvwxyz'

def main():
	for _ in range(ii()):
		(n, k) = mi()
		if n == 2:
			print(n * k - 1)
			continue
		x = k // (n - 1)
		y = k % (n - 1)
		ans = x * n + y
		if y == 0:
			ans -= 1
		print(ans)
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')

def print(*args, **kwargs):
	(sep, file) = (kwargs.pop('sep', ' '), kwargs.pop('file', sys.stdout))
	at_start = True
	for x in args:
		if not at_start:
			file.write(sep)
		file.write(str(x))
		at_start = False
	file.write(kwargs.pop('end', '\n'))
	if kwargs.pop('flush', False):
		file.flush()
if sys.version_info[0] < 3:
	(sys.stdin, sys.stdout) = (FastIO(sys.stdin), FastIO(sys.stdout))
else:
	(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
input = lambda : sys.stdin.readline().rstrip('\r\n')
main()


import math as m
for i in range(int(input())):
	(n, k) = list(map(int, input().split()))
	if k == 1:
		print(1)
	else:
		group = m.ceil(k / (n - 1))
		l = k % (n - 1)
		if k % (n - 1) == 0:
			l += n - 1
		print(n * (group - 1) + l)


from sys import stdin
import math
a = int(stdin.readline())
for b in range(0, a):
	c = stdin.readline().split()
	n = int(c[0])
	k = int(c[1])
	if k < n:
		print(k)
		continue
	A = k % (n - 1)
	B = int(math.floor(k / (n - 1)))
	if A == 0:
		print(B * n - 1)
	else:
		print(B * n + A)


import math
import sys
import bisect
inf = 10 ** 15
mod = 10 ** 9 + 7
test = int(input())
for t in range(test):
	(n, k) = map(int, input().split())
	tmp = k // (n - 1)
	amari = k % (n - 1)
	if amari == 0:
		print(tmp * n - 1)
	else:
		print(tmp * n + amari)


def solve(n, m):
	if m < n:
		print(m)
		return
	i = m // (n - 1)
	if m % (n - 1) == 0:
		i -= 1
	an = i * n
	tem = i * (n - 1)
	an += m - tem
	print(an)
t = int(input())
for _ in range(t):
	(n, k) = map(int, input().split())
	solve(n, k)


import sys
from math import ceil
read = sys.stdin.buffer.readline
mi = lambda : map(int, read().split())
li = lambda : list(mi())
cin = lambda : int(read())
ans = 1
(la, lb) = (1, 1)
for _ in range(cin()):
	(n, k) = mi()
	if n == 1:
		print(k)
	else:
		print(n * (k // (n - 1)) + [-1, k % (n - 1)][k % (n - 1) != 0])


a = int(input())
for _ in range(a):
	(x, y) = map(int, input().split())
	(rem, ans) = (0, 0)
	while y > 0:
		ans += y
		y += rem
		rem = y % x
		y = y // x
	print(ans)


def ans(n, k):
	if k < n:
		return k
	if k == n:
		return k + 1
	ans = k * n // (n - 1)
	if ans % n == 0:
		return ans - 1
	return ans
n = int(input())
for i in range(n):
	a = input().split()
	b = int(a[0])
	c = int(a[1])
	x = ans(b, c)
	print(x)


t = int(input())
while t > 0:
	(n, k) = input().split(' ')
	(n, k) = (int(n), int(k))
	v1 = k // (n - 1)
	v2 = k % (n - 1)
	if v2 == 0:
		print(n * v1 - 1)
	else:
		print(n * v1 + v2)
	t -= 1


from math import *
for _ in range(int(input())):
	(n, k) = map(int, input().split())
	(k, n) = (n, k)
	ans = 0
	while n >= k:
		x = n // k
		ans += x * k
		n = n - x * (k - 1)
	print(ans + n)


for _ in range(int(input())):
	(n, k) = [int(i) for i in input().split()]
	r = k % (n - 1)
	if r == 0:
		print(n * (k // (n - 1)) - 1)
	else:
		print(n * (k // (n - 1)) + r)


def get(l, r, mod):
	return r - l + 1 - r // mod + (l - 1) // mod
for T in range(int(input())):
	(m, k) = map(int, input().split())
	l = 1
	r = 10000000000.0
	while r - l > 1:
		med = (r + l) // 2
		if get(1, med, m) >= k:
			r = med
		else:
			l = med
	if get(1, l, m) == k:
		print(int(l))
	else:
		print(int(r))


import math
cases = int(input())
for i in range(cases):
	(n, k) = [int(p) for p in input().split()]
	if n == k:
		print(n + 1)
	else:
		print(math.ceil(k / ((n - 1) / n)) - 1)


def main():
	t = int(input())
	for _ in range(t):
		(n, k) = map(int, input().split())
		x = (k + n - 2) // (n - 1)
		print(x - 1 + k)
	return
main()


for _ in range(int(input())):
	(n, m) = input().split()
	n = int(n)
	m = int(m)
	y = int(m * n / (n - 1))
	for i in range(y, 0, -1):
		if i % n != 0:
			print(i)
			break


def readStr():
	return input()

def readInts():
	return list(map(int, readStr().split(' ')))

def main(n, k):
	x = k // (n - 1) * n
	if k % (n - 1) == 0:
		x -= 1
	else:
		x += k % (n - 1)
	return x
(t,) = readInts()
for _ in range(t):
	(n, k) = readInts()
	x = main(n, k)
	print(x)


for i in range(int(input())):
	(n, k) = map(int, input().split(' '))
	print(n * ((k + n - 2) // (n - 1) - 1) + (n - 1 if not k % (n - 1) else k % (n - 1)))


import math
import bisect
T = int(input())
for t in range(T):
	(N, K) = map(int, input().split())
	out = K
	c = K // N
	out += c
	while c != out // N:
		new = out // N
		diff = new - c
		out += diff
		c = new
	print(out)


import sys

def kth(n, k):
	length_cycle = n - 1
	number_cycles = k // length_cycle
	remainder = k % length_cycle
	correction_factor = remainder if remainder > 0 else -1
	kth_elem = number_cycles * n + correction_factor
	return kth_elem
number_loops = input()
for _ in range(int(number_loops)):
	inputs = input().split()
	print(kth(int(inputs[0]), int(inputs[1])))


import sys
readline = sys.stdin.readline
t = int(input())
for _ in range(t):
	(n, k) = map(int, readline().split())
	(ok, ng) = (10 ** 18, 0)
	while abs(ok - ng) > 1:
		mid = (ok + ng) // 2
		if mid - mid // n >= k:
			ok = mid
		else:
			ng = mid
	print(ok)


from math import floor
getK = lambda x, n: x - x // n
t = int(input())
for _ in range(t):
	(n, k) = map(int, input().split())
	if k < n:
		print(k)
	elif n == k:
		print(k + 1)
	else:
		ok = floor(k / (1 - 1 / n) - 3)
		for tt in range(ok, ok + 4):
			if getK(tt, n) == k:
				print(tt)
				break


T = int(input())
for t in range(T):
	(n, k) = [int(i) for i in input().split()]
	q = k // (n - 1)
	r = k % (n - 1)
	if r != 0:
		print(q * n + r)
	else:
		print(q * n + r - 1)


import sys
input = sys.stdin.readline

def inp():
	return int(input())

def inlt():
	return list(map(int, input().split()))

def insr():
	s = input()
	return list(s[:len(s) - 1])

def invr():
	return list(map(int, input().split()))

def solve(arr):
	res = []
	for a in arr:
		res.append(a[1] + (a[1] - 1) // (a[0] - 1))
	return res
t = inp()
arr = []
for i in range(t):
	arr.append(inlt())
res = solve(arr)
for r in res:
	print(int(r))


t = int(input())
for i in range(t):
	(a, b) = map(int, input().split())
	d = b // a
	ans = (b + d) // a
	while ans != d:
		d = (b + ans) // a
		ans = (d + b) // a
	print(b + ans)


from math import floor

def main():
	(n, k) = map(int, input().split())
	(l, r) = (0, 1e+18)
	while r - l > 1:
		mid = (r + l) // 2
		cnt = floor(mid / n)
		if mid - cnt < k:
			l = mid
		else:
			r = mid
	return int(l) + 1
t = int(input())
for _ in range(t):
	print(main())


import math
for _ in range(int(input())):
	(n, k) = map(int, input().split())
	r = n - 1
	cnt = k // r
	temp = cnt * n
	rem = k % r
	if rem == 0:
		rem = -1
	print(rem + temp)


from sys import stdin, setrecursionlimit, stdout
from collections import deque
from math import sqrt, floor, ceil, log, log2, log10, pi, gcd, sin, cos, asin

def ii():
	return int(stdin.readline())

def fi():
	return float(stdin.readline())

def mi():
	return map(int, stdin.readline().split())

def fmi():
	return map(float, stdin.readline().split())

def li():
	return list(mi())

def lsi():
	x = list(stdin.readline())
	x.pop()
	return x

def si():
	return stdin.readline().rstrip()
res = ['YES', 'NO']
test_case = ii()
while test_case:
	test_case -= 1
	(n, k) = mi()
	z = (k - 1) // (n - 1)
	p = z * n
	p += k - z * (n - 1)
	print(p)


t = int(input())
li = []
for i in range(t):
	temp = input().split()
	n = int(temp[0])
	k = int(temp[1])
	l = int(k / (n - 1))
	m = k % (n - 1)
	if m == 0:
		result = n * l - 1
	else:
		result = n * l + m
	li.append(result)
for i in range(t):
	print(int(li[i]))


import bisect
import os
from collections import Counter
import bisect
from collections import defaultdict
import math
import random
import heapq as hq
from math import sqrt
import sys
from functools import reduce, cmp_to_key
from collections import deque
import threading
from itertools import combinations
from io import BytesIO, IOBase
from itertools import accumulate

def lcm(a, b):
	return a * b // math.gcd(a, b)

def sort_dict(key_value):
	return sorted(key_value.items(), key=lambda kv: (kv[1], kv[0]))

def list_input():
	return list(map(int, input().split()))

def num_input():
	return map(int, input().split())

def string_list():
	return list(input())

def decimalToBinary(n):
	return bin(n).replace('0b', '')

def binaryToDecimal(n):
	return int(n, 2)

def solve():
	(n, k) = num_input()
	if n > k:
		print(k)
	else:
		ans = 0
		if k % (n - 1):
			ans = 1
		temp = k // (n - 1) + ans
		print(k + temp - 1)
t = int(input())
for _ in range(t):
	solve()


t = int(input())
for q in range(t):
	(n, k) = [int(i) for i in input().split()]
	if n > k:
		print(k)
		continue
	num = int(k / (n - 1)) * (n - 1)
	res = k - num
	lol = num + int(k / (n - 1)) - 1
	if res == 0:
		print(lol)
	else:
		print(res + 1 + lol)


n = int(input())
for i in range(n):
	(a, b) = input().split()
	a = int(a)
	b = int(b)
	if b > a:
		x = int(b / (a - 1))
		y = b % (a - 1)
		if b % (a - 1) != 0:
			print(x * a + y)
		else:
			print(x * a + y - 1)
	elif b == a:
		print(b + 1)
	else:
		print(b)


t = int(input())
while t:
	(n, k) = [int(n) for n in input().split()]
	need = (k - 1) // (n - 1)
	print(k + need)
	t -= 1


outputs = []
for __ in range(int(input())):
	(N, K) = (int(num) for num in input().split())
	if K % (N - 1) == 0:
		rset = K // (N - 1)
	else:
		rset = K // (N - 1) + 1
	element_parsed = (N - 1) * (rset - 1)
	outputs.append(N * (rset - 1) + (K - element_parsed))
for output in outputs:
	print(output)


def solution():
	t = int(input())
	for _ in range(t):
		(n, m) = map(int, input().split())
		x = m // n
		y = m % n
		result = m - y
		m = x + y
		while m >= n:
			x = m // n
			y = m % n
			result += m - y
			m = x + y
		print(result + m)
solution()


import io, os
input = io.BytesIO(os.read(0, os.fstat(0).st_size)).readline
t = int(input())
for _ in range(t):
	(n, k) = list(map(int, input().split()))
	s = k
	ans = k
	a = 1
	while a > 0:
		a = s // n
		b = s % n
		ans += a
		s = a + b
	print(ans)


for i in range(int(input())):
	l = input().split()
	(n, k) = (int(l[0]), int(l[1]))
	a = k // n
	while a != 0:
		k += a
		a = k // n - (k - a) // n
	if k % n != 0:
		print(k)
	else:
		print(k + 1)


def solve():
	(n, k) = map(int, input().split())
	if k % (n - 1) == 0:
		thuong = k // (n - 1) - 1
		du = n - 1
	else:
		thuong = k // (n - 1)
		du = k % (n - 1)
	print(n * thuong + du)
for i in ' ' * int(input()):
	solve()


def solution(n, k):
	if k % (n - 1) == 0:
		delta = -1
	else:
		delta = k % (n - 1)
	print(n * (k // (n - 1)) + delta)
inp = int(input())
for _ in range(inp):
	input_ = tuple(map(int, input().split()))
	solution(input_[0], input_[1])


t = int(input())
for i in range(t):
	(n, k) = (int(x) for x in input().split())
	dm = divmod(k, n - 1)
	if dm[1] == 0:
		print(n * dm[0] + dm[1] - 1)
	else:
		print(n * dm[0] + dm[1])


n = int(input())
for o in range(n):
	(a, b) = map(int, input().split())
	k = (b - 1) // (a - 1)
	print(b + k)


def solve(n, k):
	old_mod = 0
	new_mod = k // n
	num = k
	while new_mod != old_mod:
		num = num + new_mod - old_mod
		old_mod = new_mod
		new_mod = num // n
	print(num)
t = int(input())
for _ in range(t):
	(n, k) = map(int, input().split())
	solve(n, k)


t = int(input())
for _ in range(t):
	(n, k) = [int(i) for i in input().split()]
	possi = n - 1
	num = k // possi
	rem = k % possi
	ans = n * num
	ans += rem
	if rem == 0:
		ans -= 1
	print(ans)


import math

def check(N, K):
	return K + math.floor((K - 1) / (N - 1))
for _ in range(int(input())):
	(n, k) = list(map(int, input().split()))
	print(check(n, k))


def main():
	t = int(input())
	while t != 0:
		lst = list(map(int, input().strip().split()))
		n = lst[0]
		k = lst[1]
		setSize = n - 1
		steps = k // setSize
		remainder = k % setSize
		total = steps * n - 1
		if remainder > 0:
			total += remainder + 1
		print(total)
		t -= 1
main()


t = int(input())
for q in range(t):
	(n, k) = [int(i) for i in input().split(' ')]
	x = 0
	while 1:
		x_old = x
		x = k // n
		k += x - x_old
		if x - x_old == 0:
			break
	print(k)


t = int(input())
while t > 0:
	t = t - 1
	(n, k) = map(int, input().split())
	c = k // n
	d = c
	k = k + c
	while k // n != d:
		d = k // n
		k = k + k // n - c
		c = d
	print(k)


number = int(input())
while number > 0:
	(n, k) = map(int, input().split())
	print((k - 1) // (n - 1) + k)
	number -= 1


for _ in range(int(input())):
	(k, n) = map(int, input().split())
	cou = 0
	j = n
	for i in range(n ** 2):
		if n < k:
			break
		cou += n // k
		n = n // k + n % k
	print(j + cou)


def RA():
	return list(map(int, input().split()))

def solve():
	(n, k) = RA()
	rep = n - 1
	count = k // rep
	remainder = k % rep
	if remainder == 0:
		print(n * (count - 1) + rep)
	else:
		print(n * count + remainder)
t = int(input())
for i in range(t):
	solve()


n = int(input())
for i in range(n):
	arr = list(map(int, input().split()))
	a = arr[0]
	b = arr[1]
	mult = b // (a - 1)
	add = b % (a - 1)
	if b < a:
		print(b)
	elif add == 0:
		print(a * mult - 1)
	else:
		print(a * mult + add)


t = int(input())
for _ in range(t):
	(n, k) = list(map(int, input().split()))
	r = k // n
	newk = k + r
	while True:
		prev = newk
		r = newk // n
		newk = k + r
		if newk == prev:
			break
	print(newk)