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>
using namespace std;
void E(){puts("0");exit(0);}
const int N=1505,mo=998244353,iv2=mo+1>>1;
inline void add(int&a,const int&b){a+=b-mo;a+=a>>31&mo;}
int n,i,j,g[N],aa[N];
char c[N][N];
vector<int>e[N][N];
int tp[N][N];
bool bb[N];
int gfa(int x){return g[x]==x?x:g[x]=gfa(g[x]);}
inline int solve(vector<int>v){
	for(int i:v)for(int j:v)if(i<j){
		bool fl1=0,fl2=0;
		for(int x:e[i][j])fl1|=x=='o',fl2|=x=='x';
		if(fl1 && fl2)E();
		tp[i][j]=fl1?1:fl2?0:-1;
	}
	int ans=1;
	if(v.size()&1){
		for(i=0;i<v.size();++i)for(j=i+1;j<v.size();++j){
			int w=tp[v[i]][v[j]];
			if(w==-1)g[gfa(v[i])]=gfa(v[j]);
				else aa[v[i]]^=w,aa[v[j]]^=w;
		}
		static int b[N],ec[N],vc[N];
		for(i=0;i<v.size();++i)b[gfa(v[i])]^=aa[v[i]],++vc[gfa(v[i])];
		for(int i:v)if(b[i])E();
		for(i=0;i<v.size();++i)for(j=i+1;j<v.size();++j)if(tp[v[i]][v[j]]==-1)++ec[gfa(v[i])];
		for(int i:v)if(gfa(i)==i)for(int j=vc[i];j<=ec[i];++j)ans=2ll*ans%mo;
	}else{
		for(i=0;i<v.size();++i)for(j=i+1;j<v.size();++j)if(tp[v[i]][v[j]]==-1)ans=2ll*ans%mo;
	}
	return ans;
}
int main(){
	scanf("%d",&n);for(i=1;i<n;++i)scanf("%s",c[i]+1);
	for(i=1;i<n;++i)for(j=1;j<n;++j){
		int p=abs(i-j),q=n-abs(n-j-i);
		if(p>q)swap(p,q);e[p][q].push_back(int(c[i][j]));
	}
	vector<int>ve1,ve2;
	for(i=0;i<=n;i+=2)ve1.push_back(i);for(i=1;i<=n;i+=2)ve2.push_back(i);
	for(i=0;i<=n;++i)g[i]=i;
	printf("%lld\n",1ll*solve(ve1)*solve(ve2)%mo);
}