#include int main(void) { int Q; int n[10000]; int e; int i, k, j; scanf("%d", &Q); for (i = 0; i < Q; i++) { scanf("%d", &n[i]); } for (k = 0; k < Q; k++) { int a = 0; int b = 0; int c = 0; int d = 1; if (n[k] < 4) { printf("0\n"); } else if (n[k] == 4) { printf("1\n"); } else { for (j = 5; j <= n[k]; j++) { e = (a + b + c + d) % 17; a = b; b = c; c = d; d = e; } printf("%d\n", e); } } return 0; }