import java.util.HashMap;
import java.util.Scanner;

public class Array {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);

        //System.out.println(1000000000);
        int n = scanner.nextInt();


        long[][] tmp = new long[35][35];
        HashMap<Long, Integer> hladac = new HashMap<>();
        for (int i = 0; i < tmp.length; i++) {
            boolean end = false;
            for (int j = 0; j < i+1; j++) {
                if (j == 0 || j == i) {
                    tmp[i][j] = 1;
                } else {
                    tmp[i][j] = tmp[i-1][j-1] + tmp[i-1][j];
                    if (!hladac.containsKey(tmp[i][j])) {
                        hladac.put(tmp[i][j],i+1);
                    }
                }
            }
        }


        for (int i = 0; i < n; i++) {
            long cislo = scanner.nextInt();

            if (cislo == 1) {
                System.out.println("1");
            } else {
                System.out.println(hladac.get(cislo));
            }
        }

        /*int i = 1;
        for (long[] ints : tmp) {
            System.out.print(i + ": ");
            i++;
            for (long anInt : ints) {
                System.out.print(anInt + " ");
                if (anInt >= Math.pow(10,9)) {
                    System.out.println("go it");
                    break;
                }
            }
            System.out.println();
        }*/

        // 1
        // 1 1
        // 1 2 1
        // 1 3 3 1
        // 1 4 6 4 1
        // 1 5 10 5 1
    }
}
