#include using namespace std; #define rep(i, n) for (int i=0; i T; int N; int A[18], B[18], C[18]; vector> L; int dp[1<<18][18][8]; signed main() { cin >> N; rep(i, N) cin >> A[i] >> B[i] >> C[i]; rep(i, N) { vector v; v.pb(make_tuple(A[i], B[i], C[i])); v.pb(make_tuple(A[i], C[i], B[i])); v.pb(make_tuple(B[i], A[i], C[i])); v.pb(make_tuple(B[i], C[i], A[i])); v.pb(make_tuple(C[i], A[i], B[i])); v.pb(make_tuple(C[i], B[i], A[i])); L.pb(v); } rep(i, N) rep(j, 6) dp[1<(L[i][j]); rep(S, 1<>i)&1)) continue; rep(j, N) { if ((S>>j)&1) continue; rep(k, 6) rep(l, 6) { int pa = get<0>(L[i][k]), pb = get<1>(L[i][k]); int a = get<0>(L[j][l]), b = get<1>(L[j][l]), c = get<2>(L[j][l]); if (pa>=a && pb>=b) dp[S|(1<