#include using namespace std; using ll = long long; int main(){ ios::sync_with_stdio(false); cin.tie(0); int n; cin >> n; vector A(n); for(auto &&str : A) cin >> str; int b = 2 * (n - 1), ans = 0; string tmp(b + 1, '?'); auto check = [&](){ int l = 0, r = tmp.size() - 1; while(l < r){ if(tmp[l] != tmp[r]) return false; l++, r--; } return true; }; for(int comb = (1 << (n - 1)) - 1; comb < (1 << b); ){ { int y = 0, x = 0; for(int i = 0; i < b; i++){ tmp[i] = A[y][x]; if(comb >> i & 1) x++; else y++; } tmp.back() = A[y][x]; ans += check(); } int x = comb & (-comb), y = comb + x; comb = ((comb & ~y) / x >> 1) | y; } cout << ans << '\n'; }