// // main.cpp // bc75.2 // // Created by eycia on 16/3/12. // Copyright © 2016年 eycia. All rights reserved. // #include #include int mp[10][10]; int cant[16][3] = { {1, 3, 2}, {3, 1, 2}, {4, 6, 5}, {6, 4, 5}, {7, 9, 8}, {9, 7, 8}, {1, 7, 4}, {7, 1, 4}, {2, 8, 5}, {8, 2, 5}, {3, 9, 6}, {9, 3, 6}, {1, 9, 5}, {9, 1, 5}, {3, 7, 5}, {7, 3, 5}}; bool v[10]; int main(int argc, const char * argv[]) { int t; memset(mp, 0, sizeof(mp)); for (int i = 0; i < 16; i++) { mp[cant[i][0]][cant[i][1]] = cant[i][2]; } scanf("%d", &t); while (t--) { int k, n, lst = 0; for (int i = 0; i < 10; i++) { v[i] = false; } v[0] = true; bool result = true; scanf("%d", &k); if (k < 4) result&=false; for (int i = 0; i < k; i++) { scanf("%d", &n); if (!result) continue; if (n >= 10 || n <= 0) { result &= false; continue; } if (!v[n]) { v[n] = true; } else { result &= false; continue; } if (!v[mp[lst][n]]) { result &= false; continue; } lst = n; } if (result) { puts("valid"); } else { puts("invalid"); } } }