#include<bits/stdc++.h>

using namespace std;

typedef long long LL;
#define N 1600

const int mod=998244353;
int n,sz,num,sum,ans,f[N][N],g[N][N];
bool vis[N];
char s[N];

void upd(int x,int y,char ch){
	if (x>y) swap(x,y);
	if (ch=='?') return;
	if (ch=='o'){
		if (f[x][y]==0){puts("0"); exit(0);}
		f[x][y]=1;
	}
	if (ch=='x'){
		if (f[x][y]==1){puts("0"); exit(0);}
		f[x][y]=0;
	}
}

void dfs(int u,int n){
	vis[u]=1; ++sz;
	for (int i=0;i<u;++i)
		if (g[i][u]==-1){
			++num;
			if (!vis[i]) dfs(i,n);
		}
		else sum^=g[i][u];
	for (int i=u+1;i<=n;++i)
		if (g[u][i]==-1){
			++num;
			if (!vis[i]) dfs(i,n);
		}
		else sum^=g[u][i];
}

int solve(int n){
	int ret=1;
	if (n&1){
		for (int i=0;i<=n;++i)
			for (int j=i+1;j<=n;++j)
				if (g[i][j]==-1) ret=ret*2%mod;
	}
	else{
		memset(vis,0,sizeof vis);
		for (int i=0;i<=n;++i)
			if (!vis[i]){
				sz=0; sum=0; num=0; dfs(i,n);
				if (sum){puts("0"); exit(0);}
				for (num/=2,num-=sz-1;num;--num) ret=ret*2%mod;
			}
	}
	return ret;
}

int main(){
	scanf("%d",&n);
	memset(f,-1,sizeof f);
	for (int i=1;i<n;++i){
		scanf("%s",s+1);
		for (int j=1;j<n;++j){
			int x=min(i+j,n*2-i-j),y=abs(i-j);
			upd(x,y,s[j]);
		}
	}
	memset(g,-1,sizeof g);
	for (int i=0;i<=n;i+=2)
		for (int j=i+2;j<=n;j+=2) g[i/2][j/2]=f[i][j];
	ans=solve((n-(n&1))/2);
	memset(g,-1,sizeof g);
	for (int i=1;i<=n;i+=2)
		for (int j=i+2;j<=n;j+=2) g[i/2][j/2]=f[i][j];
	ans=(LL)ans*solve((n-!(n&1))/2)%mod;
	printf("%d\n",ans);
	
	return 0;
}
			