/* Name: Author: xiaruize Date: */ #include<bits/stdc++.h> usingnamespace std; #define int long long #define ull unsigned long long #define ALL(a) (a).begin(), (a).end() #define pb push_back #define mk make_pair #define pii pair<int, int> #define pis pair<int, string> #define sec second #define fir first #define sz(a) int((a).size()) #define rep(i, x, y) for (int i = x; i <= y; i++) #define repp(i, x, y) for (int i = x; i >= y; i--) #define Yes cout << "Yes" << endl #define YES cout << "YES" << endl #define No cout << "No" << endl #define NO cout << "NO" << endl #define debug(x) cerr << #x << ": " << x << endl #define double long double constint INF = 0x3f3f3f3f; constint MOD = 1000000007; constint N = 2e5 + 10;
// bool st; int n; int a[25][25]; map<int, int> mp[25]; // bool en;
signedmain() { // freopen(".in","r",stdin); // freopen(".out","w",stdout); // cerr<<(&en-&st)/1024.0/1024.0<<endl; // auto t_1=chrono::high_resolution_clock::now(); cin >> n; for (int i = 1; i <= n; i++) for (int j = 1; j <= n; j++) cin >> a[i][j]; int h = n - 1; for (int i = 0; i < (1 << h); i++) { int x = 1, y = 1, st = a[1][1]; for (int j = 0; j < h; j++) { if (i & (1 << j)) x++; else y++; st ^= a[x][y]; } mp[x][st]++; // cerr << x << ' ' << st << endl; } int res = 0; for (int i = 0; i < (1 << h); i++) { int x = n, y = n, st = a[n][n]; for (int j = 0; j < h; j++) { if (i & (1 << j)) x--; else y--; st ^= a[x][y]; } st ^= a[x][y]; // cerr << st << endl; res += mp[x][st]; } cout << res << endl; // auto t_2=chrono::high_resolution_clock::now(); // cout <<". Elapsed (ms): " << chrono::duration_cast<chrono::milliseconds>(t_2 - t_1).count() << endl; return0; }