from fractions import gcd from datetime import date, timedelta from heapq import* import math from collections import defaultdict, Counter,deque import sys from bisect import * import itertools import copy sys.setrecursionlimit(10 ** 7) MOD = 10 ** 9 + 7 def main(): q = int(input()) for i in range(q): n, k = map(int, input().split()) if k == 1: print(n - 1) continue ans = 0 kt = k while kt <= n: kt *= 2 ans += 1 print(ans) if __name__ == '__main__': main()