import java.util.*; public class Main { static final int MOD = 17; public static void main (String[] args) { Scanner sc = new Scanner(System.in); int q = sc.nextInt(); int[] arr = new int[1000001]; arr[4] = 1; for (int i = 5; i <= 1000000; i++) { arr[i] = (arr[i - 1] + arr[i - 2] + arr[i - 3] + arr[i - 4]) % MOD; } StringBuilder sb = new StringBuilder(); for (int i = 0; i < q; i++) { sb.append(arr[sc.nextInt()]).append("\n"); } System.out.print(sb); } }