#include #include int main(void) { int i, j, a[5], Q, n, Max; scanf("%d", &Q); int *b = (int *)calloc(Q, sizeof(int)); for (j = 0; j < Q; j++) { scanf("%d", &n); b[j] = n; Max = 0; if (b[j] > Max) { Max = b[j]; } } int *c = (int *)calloc(Max, sizeof(int)); a[0] = 0; a[1] = 0; a[2] = 0; a[3] = 1; c[0] = 0; c[1] = 0; c[2] = 0; c[3] = 0; for (i = 0; i < Max - 3; i++) { a[4] = (a[3] + a[2] + a[1] + a[0]) % 17; a[0] = a[1]; a[1] = a[2]; a[2] = a[3]; a[3] = a[4]; c[i + 4] = a[4] % 17; } for (j = 0; j < Q; j++) { printf("%d", c[b[j]]); printf("\n"); } return 0; }