//#pragma GCC optimize("Ofast")
//#pragma GCC target("avx")
//#undef LOCAL
#include <bits/stdc++.h>

using namespace std;
using uint = unsigned int;
using ll = long long;
using ull = unsigned long long;
constexpr ll TEN(int n) { return (n == 0) ? 1 : 10 * TEN(n - 1); }
template <class T> using V = vector<T>;
template <class T> using VV = V<V<T>>;

#ifdef LOCAL
struct PrettyOS {
    ostream& os;
    bool first;
    template <class T> auto operator<<(T&& x) {
        if (!first) os << ", ";
        first = false;
        os << x;
        return *this;
    }
};
template <class... T> void dbg0(T&&... t) {
    (PrettyOS{cerr, true} << ... << t);
}
#define dbg(...)                                            \
    do {                                                    \
        cerr << __LINE__ << " : " << #__VA_ARGS__ << " = "; \
        dbg0(__VA_ARGS__);                                  \
        cerr << endl;                                       \
    } while (false);
#else
#define dbg(...)
#endif

template <class T, class U>
ostream& operator<<(ostream& os, const pair<T, U>& p) {
    return os << "P(" << p.first << ", " << p.second << ")";
}

template <class T> ostream& operator<<(ostream& os, const V<T>& v) {
    os << "[";
    for (auto d : v) os << d << ", ";
    return os << "]";
}

template <uint MD> struct ModInt {
    using M = ModInt;
    const static M G;
    uint v;
    ModInt(ll _v = 0) { set_v(_v % MD + MD); }
    M& set_v(uint _v) {
        v = (_v < MD) ? _v : _v - MD;
        return *this;
    }
    explicit operator bool() const { return v != 0; }
    M operator-() const { return M() - *this; }
    M operator+(const M& r) const { return M().set_v(v + r.v); }
    M operator-(const M& r) const { return M().set_v(v + MD - r.v); }
    M operator*(const M& r) const { return M().set_v(ull(v) * r.v % MD); }
    M operator/(const M& r) const { return *this * r.inv(); }
    M& operator+=(const M& r) { return *this = *this + r; }
    M& operator-=(const M& r) { return *this = *this - r; }
    M& operator*=(const M& r) { return *this = *this * r; }
    M& operator/=(const M& r) { return *this = *this / r; }
    bool operator==(const M& r) const { return v == r.v; }
    M pow(ll n) const {
        M x = *this, r = 1;
        while (n) {
            if (n & 1) r *= x;
            x *= x;
            n >>= 1;
        }
        return r;
    }
    M inv() const { return pow(MD - 2); }
    friend ostream& operator<<(ostream& os, const M& r) { return os << r.v; }
};
using Mint = ModInt<998244353>;
// template<> const Mint Mint::G = Mint(3);

struct QuickFind {
    V<int> id;
    VV<int> groups;
    int gc;  // group count
    QuickFind(int n = 0) {
        id = V<int>(n);
        groups = VV<int>(n);
        for (int i = 0; i < n; i++) {
            id[i] = i;
            groups[i] = {i};
        }
        gc = n;
    }
    void merge(int a, int b) {
        if (same(a, b)) return;
        gc--;
        int x = id[a], y = id[b];
        if (groups[x].size() < groups[y].size()) swap(x, y);
        for (int j : groups[y]) {
            id[j] = x;
            groups[x].push_back(j);
        }
        groups[y].clear();
    }
    bool same(int a, int b) { return id[a] == id[b]; }
};

void No() {
    cout << 0 << endl;
    exit(0);
}

Mint solve(VV<int> g) {
    int n = int(g.size());
    if (n % 2 == 0) {
        int rnk = 0;
        for (int i = 0; i < n; i++) {
            for (int j = i + 1; j < n; j++) {
                if (g[i][j] == -1) rnk++;
            }
        }
        return Mint(2).pow(rnk);
    }
    int rnk = 0;
    V<int> deg(n);
    auto qf = QuickFind(n);
    for (int i = 0; i < n; i++) {
        for (int j = i + 1; j < n; j++) {
            if (g[i][j] == -1) {
                rnk++;
                qf.merge(i, j);
            } else {
                deg[i] ^= g[i][j];
                deg[j] ^= g[i][j];
            }
        }
    }

    for (auto gr: qf.groups) {
        int sm = 0;
        for (int v: gr) {
            sm ^= deg[v];
        }
        if (gr.size()) {
            rnk -= int(gr.size()) - 1;
        }
        if (sm) No();
    }

    return Mint(2).pow(rnk);
}

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(20);
    int n;
    cin >> n;
    int ln = (n + 1) / 2, rn = n + 1 - ln;
    VV<int> g0(rn, V<int>(rn, -1));
    VV<int> g1(ln, V<int>(ln, -1));
    for (int i = 1; i < n; i++) {
        string s;
        cin >> s;
        for (int j = 1; j < n; j++) {
            char c = s[j - 1];
            if (c == '?') continue;
            int f = (c == 'o') ? 1 : 0;
            int d0 = abs(j - i);
            int d1 = n - abs(j + i - n);
            dbg(i, j, d0, d1);
            if (d0 % 2 == 0) {
                d0 /= 2; d1 /= 2;
                if (g0[d0][d1] == 1 - f) {
                    No();
                }
                g0[d0][d1] = g0[d1][d0] = f;
            } else {
                d0 /= 2; d1 /= 2;
                if (g1[d0][d1] == 1 - f) {
                    No();
                }
                g1[d0][d1] = g1[d1][d0] = f;
            }
        }
    }

    dbg(g0);
    dbg(g1);

    Mint ans = solve(g0) * solve(g1);
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 9216