import java.util.*; public class Main { static int MAX = 1000000; public static void main (String[] args) { Scanner sc = new Scanner(System.in); int[] arr = new int[MAX]; arr[3] = 1; 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++) { sb.append(arr[sc.nextInt() - 1]).append("\n"); } System.out.print(sb); } }