#include #include #include #include #include #include #include #include #include #include #include #include #include #define debug_value(x) cerr << "line" << __LINE__ << ":<" << __func__ << ">:" << #x << "=" << x << endl; #define debug(x) cerr << "line" << __LINE__ << ":<" << __func__ << ">:" << x << endl; template inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; } template inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; } using namespace std; typedef long long ll; template vector> vec2d(int n, int m, T v){ return vector>(n, vector(m, v)); } template vector>> vec3d(int n, int m, int k, T v){ return vector>>(n, vector>(m, vector(k, v))); } template void print_vector(vector v, char delimiter=' '){ if(v.empty()) { cout << endl; return; } for(int i = 0; i+1 < v.size(); i++) cout << v[i] << delimiter; cout << v.back() << endl; } vector vv = {1, 3, 4, 5}; vector uu = {2, 2, 2, 0}; int main(){ ios::sync_with_stdio(false); cin.tie(0); cout << setprecision(10) << fixed; int n; cin >> n; vector a(6); for(int i = 0; i < 6; i++) cin >> a[i]; if(n == 0){ cout << "NO" << endl; return 0; } int mx = [&](){ if(n == 1) return 0; if(n == 2) return 1; if(n == 3) return 3; if(n == 4) return 15; if(n == 5) return (1<<16)-1; }(); for(int x = 0; x <= 15; x++){ for(int y = 0; y <= 15; y++){ for(int z = 0; z <= 15; z++){ if(max({x, y, z}) > mx) continue; vector v = {x, y, z}; auto ok = [&](){ vector b(6); for(int i = 0; i < 6; i++) b[i] = v[a[i]]; if((b[0]&b[3]) != b[3]) return false; for(int i = 0; i < 4; i++){ int j = vv[i]; int k = uu[i]; if((b[k]&(1<