# Divide n by 2^k using float
# If whole number, return 1
# If decimal, return 2
# Should this work?

from math import floor
# 536870912 30
for _ in range(int(input())):
	n, k = map(int, input().split())
	res = n/(2**k)
	if res == floor(res): print(1)
	else: print(2)