def next_row(x, i):
    arr: list = [1]
    for c in range(1, (i+1) // 2):
        arr.append(x[c - 1] + x[c])
    if i > 0:
        arr.append(2 * x[-1] if i % 2 != 0 else x[-1] + x[-2])
    return arr


num_of_req = int(input())

for _ in range(num_of_req):
    # x = [1]
    # for i in range(0, 7):
    #     print(x)
    #     x = next_row(x, i)

    to_find = int(input())
    x = [1]
    i = 0
    while to_find not in x:
        x = next_row(x, i)
        i += 1

    print(i+1)
