import java.util.*; public class Main { static int MAX = 5000; static int MOD = 4912; public static void main (String[] args) { Scanner sc = new Scanner(System.in); int[] arr = new int[MAX]; arr[3] = 1; HashMap map = new HashMap<>(); for (int i = 4; i < MAX; i++) { arr[i] = (arr[i - 1] + arr[i - 2] + arr[i - 3] + arr[i - 4]) % 17; } int n = sc.nextInt(); StringBuilder sb = new StringBuilder(); for (int i = 0; i < n; i++) { long x = sc.nextLong() - 1; int idx; if (x >= 4) { idx = (int)((x - 4) % MOD + 4); } else { idx = (int)x; } sb.append(arr[idx]).append("\n"); } System.out.print(sb); } }