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[5001]; arr[4] = 1; TreeSet set = new TreeSet<>(); for (int i = 5; i <= 5000; 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++) { int idx = (int)((sc.nextLong() - 1) % 4912 + 1); sb.append(arr[idx]).append("\n"); } System.out.println(sb); } }