def next_row(x):
    arr: list = [1]

    for i in range(1,len(x)):
        arr.append(x[i-1]+x[i])
    arr.append(1)
    return arr

num_of_req = int(input())

for _ in range(num_of_req):
    to_find = int(input())
    x = [1]
    i = 1
    while to_find not in x:
        x = next_row(x)
        i += 1

    print(i)

