#include <bits/stdc++.h>
using namespace std;
int n;
int t[20][20];
map<int, int> cnt[20][20];
long long ans = 0;
void dfs_first(int i, int j, int x) {
if (i + j == n - 1) {
cnt[i][j][x]++;
return;
}
if (i + 1 < n) dfs_first(i + 1, j, x ^ t[i][j]);
if (j + 1 < n) dfs_first(i, j + 1, x ^ t[i][j]);
}
void dfs_second(int i, int j, int x) {
if (i + j == n - 1) {
if (cnt[i][j].count(x ^ t[i][j]))
ans += cnt[i][j][x ^ t[i][j]];
return;
}
if (i - 1 >= 0) dfs_second(i - 1, j, x ^ t[i][j]);
if (j - 1 >= 0) dfs_second(i, j - 1, x ^ t[i][j]);
}
int main() {
cin >> n;
for (int i = 0; i < n; ++i)
for (int j = 0; j < n; ++j)
cin >> t[i][j];
dfs_first(0, 0, 0);
dfs_second(n - 1, n - 1, 0);
cout << ans << '\n';
return 0;
}