import java.io.*; import java.util.*; public class Main_yukicoder657 { private static Scanner sc; private static Printer pr; private static void solve() { int q = sc.nextInt(); int[] n = new int[q]; for (int i = 0; i < q; i++) { n[i] = sc.nextInt(); } int[] t = new int[1_000_000]; t[3] = 1; for (int i = 4; i < 1_000_000; i++) { t[i] = (t[i - 1] + t[i - 2] + t[i - 3] + t[i - 4]) % 17; } for (int i = 0; i < q; i++) { pr.println(t[n[i] - 1]); } } // --------------------------------------------------- public static void main(String[] args) { sc = new Scanner(System.in); pr = new Printer(System.out); solve(); pr.close(); sc.close(); } private static class Printer extends PrintWriter { Printer(PrintStream out) { super(out); } } }