import java.util.Scanner; public class Main { public static void main(String[] args) { Scanner scan = new Scanner(System.in); int Q = scan.nextInt(); int max = (int)Math.pow(10, 6) + 1; int[]T = new int[max]; T[0] = 0; T[1] = 0; T[2] = 0; T[3] = 1; for(int i = 4; i < max; i++) { T[i] = (T[i - 1] + T[i - 2] + T[i - 3] + T[i - 4]) % 17; } StringBuilder sb = new StringBuilder(); for(int i = 0; i < Q; i++) { int n = scan.nextInt(); sb.append(T[n - 1]); sb.append("\n"); } scan.close(); System.out.print(sb.toString()); } }