In a two-dimensional plane, there is a square frame whose vertices are at coordinates (0,0), (N,0), (0,N), and (N,N). The frame is made of mirror glass. A ray of light striking an edge of the frame (but not a vertex) will be reflected so that the angle of incidence is equal to the angle of reflection. A ray of light striking a vertex of the frame will be reflected in the direction opposite to the direction it is coming from.

We will define the path for a grid point (a point with integer coordinates) (i,j) (0<i,j<N) strictly within the frame, as follows:

* The path for (i,j) is the union of the trajectories of four rays of light emitted from (i,j) to (i-1,j-1), (i-1,j+1), (i+1,j-1), and (i+1,j+1).



<image>

Figure: an example of a path for a grid point

There is a light bulb at each grid point strictly within the frame. We will assign a state - ON or OFF - to each bulb. The state of the whole set of bulbs are called beautiful if it is possible to turn OFF all the bulbs by repeating the following operation:

* Choose a grid point strictly within the frame, and switch the states of all the bulbs on its path.



Takahashi has set the states of some of the bulbs, but not for the remaining bulbs. Find the number of ways to set the states of the remaining bulbs so that the state of the whole set of bulbs is beautiful, modulo 998244353. The state of the bulb at the grid point (i,j) is set to be ON if A_{i,j}=`o`, OFF if A_{i,j}=`x`, and unset if A_{i,j}=`?`.

Constraints

* 2 \leq N \leq 1500
* A_{ij} is `o`, `x`, or `?`.

Input

Input is given from Standard Input in the following format:


N
A_{1,1}...A_{1,N-1}
:
A_{N-1,1}...A_{N-1,N-1}


Output

Print the answer.

Examples

Input

4
o?o
???
?x?


Output

1


Input

5
o?o?
????
o?x?
????


Output

0


Input

6
?o???
????o
??x??
o????
???o?


Output

32


Input

9
????o??x
?????x??
??o?o???
?o?x????
???????x
x?o?o???
????????
x?????x?


Output

4
#include<bits/stdc++.h>
#define ll long long
#define ull unsigned ll
#define uint unsigned
#define pii pair<int,int>
#define pll pair<ll,ll>
#define IT iterator
#define PB push_back
#define fi first
#define se second
#define For(i,j,k) for (int i=(int)(j);i<=(int)(k);i++)
#define Rep(i,j,k) for (int i=(int)(j);i>=(int)(k);i--)
#define UPD(x,y) (((x)+=(y))>=mo?x-=mo:233)
#define CLR(a,v) memset(a,v,sizeof(a));
#define CPY(a,b) memcpy(a,b,sizeof(a));
#define debug puts("wzpakking")
using namespace std;
const int N=1505;
const int mo=998244353;
int a[N][N],n,ans;
int deg[N],vis[N];
int S1,S2,S3,GG;
vector<int> e[N];
char s[N];
void dfs(int x){
	++S3;
	S1^=deg[x];
	S2+=e[x].size();
	vis[x]=1;
	For(i,0,e[x].size()-1)
		if (!vis[e[x][i]])
			dfs(e[x][i]);
}
int main(){
	scanf("%d",&n);
	For(i,0,n) For(j,0,n) a[i][j]=-1;
	For(i,1,n-1){
		scanf("%s",s+1);
		For(j,1,n-1){
			int c=-1;
			int v1=abs(i-j),v2=n-abs(n-i-j);
			if (v1>v2) swap(v1,v2);
			if (s[j]=='x') c=0;
			if (s[j]=='o') c=1;
			if (c!=-1&&a[v1][v2]!=-1&&c!=a[v1][v2]) GG=1;
			if (c!=-1) a[v1][v2]=c;
		}
	}
	if (GG)
		return puts("0"),0;
	For(i,1,n-1) For(j,1,n-1){
		int v1=i-j,v2=i+j;
		if (v1>=0&&v2<=n){
			//printf("%d %d\n",i,j);
			if (a[v1][v2]==-1){
				e[v1].PB(v2);
				e[v2].PB(v1);
				//printf("edge %d %d\n",v1,v2); 
			}
			else if (a[v1][v2]==1)
				deg[v1]^=1,deg[v2]^=1;
		}
	}
	int ans=1;
	For(i,0,n) if (!vis[i]){
		S1=S2=S3=0; dfs(i); S2/=2;
		int cnt=(i&1?(n+1)/2:n/2+1);
		if (cnt&1){
			if (S1) return puts("0"),0;
			S2-=S3-1;
		}
		For(j,1,S2)
			ans=2ll*ans%mo;
	}
	printf("%d",ans);
}