using System; using System.Collections.Generic; using System.Linq; using static System.Console; class Program { static void Main() { var T = new int[4912]; T[3] = 1; for (int i = 4; i < 4912; i++) T[i] = (T[i - 1] + T[i - 2] + T[i - 3] + T[i - 4]) % 17; var Q = int.Parse(ReadLine()); for (int i = 0; i < Q; i++) WriteLine(T[(int.Parse(ReadLine()) - 1) % 4912]); } }