#include #include #include using namespace std; int main() { int n; cin >> n; vector c(n); for (int i = 0; i < n; ++i) cin >> c[i]; int ans = 0; string now = ""; auto dfs = [&](auto f, int x, int y) -> void { if (x == n - 1 && y == n - 1) { now.push_back(c[x][y]); string tmp = now; reverse(tmp.begin(), tmp.end()); ans += (tmp == now); now.pop_back(); return; } now.push_back(c[x][y]); if (x + 1 < n) f(f, x + 1, y); if (y + 1 < n) f(f, x, y + 1); now.pop_back(); }; dfs(dfs, 0, 0); cout << ans << endl; }