using System; using System.Collections.Generic; using System.Linq; using static System.Console; class Program { static void Main() { var Q = int.Parse(ReadLine()); var n = new int[Q]; for (int i = 0; i < Q; i++) { n[i] = int.Parse(ReadLine()); } for (int i = 0; i < Q; i++) { var T = new int[n[i]]; if (n[i] <= 4) { switch (n[i]) { case 1: case 2: case 3: WriteLine(0); break; default: WriteLine(1); break; } } else { T[3] = 1; for (int j = 4; j < n[i]; j++) { T[j] = (T[j - 1] + T[j - 2] + T[j - 3] + T[j - 4]) % 17; } WriteLine(T.Last()); } } } }