Ringo got interested in modern art. He decided to draw a big picture on the board with N+2 rows and M+2 columns of squares constructed in the venue of CODE FESTIVAL 2017, using some people.

The square at the (i+1)-th row and (j+1)-th column in the board is represented by the pair of integers (i,j). That is, the top-left square is (0,0), and the bottom-right square is (N+1,M+1). Initially, the squares (x,y) satisfying 1 \leq x \leq N and 1 \leq y \leq M are painted white, and the other (outermost) squares are painted black.

Ringo arranged people at some of the outermost squares, facing inward. More specifically, the arrangement of people is represented by four strings A, B, C and D, as follows:

* For each row except the top and bottom, if the i-th character (1 \leq i \leq N) in A is `1`, place a person facing right at the square (i,0); otherwise, do nothing.
* For each row except the top and bottom, if the i-th character (1 \leq i \leq N) in B is `1`, place a person facing left at the square (i,M+1); otherwise, do nothing.
* For each column except the leftmost and rightmost, if the i-th character (1 \leq i \leq M) in C is `1`, place a person facing down at the square (0,i); otherwise, do nothing.
* For each column except the leftmost and rightmost, if the i-th character (1 \leq i \leq M) in D is `1`, place a person facing up at the square (N+1,i); otherwise, do nothing.



Each person has a sufficient amount of non-white paint. No two people have paint of the same color.

<image>

An example of an arrangement of people (For convenience, black squares are displayed in gray)

Ringo repeats the following sequence of operations until all people are dismissed from the venue.

* Select a person who is still in the venue.
* The selected person repeats the following action while the square in front of him/her is white: move one square forward, and paint the square he/she enters with his/her paint. When the square in front of him/her is not white, he/she stops doing the action.
* The person is now dismissed from the venue.



<image>

An example of a way the board is painted

How many different states of the board can Ringo obtain at the end of the process? Find the count modulo 998244353.

Two states of the board are considered different when there is a square painted in different colors.

Constraints

* 1 \leq N,M \leq 10^5
* |A|=|B|=N
* |C|=|D|=M
* A, B, C and D consist of `0` and `1`.

Input

Input is given from Standard Input in the following format:


N M
A
B
C
D


Output

Print the number of the different states of the board Ringo can obtain at the end of the process, modulo 998244353.

Examples

Input

2 2
10
01
10
01


Output

6


Input

2 2
11
11
11
11


Output

32


Input

3 4
111
111
1111
1111


Output

1276


Input

17 21
11001010101011101
11001010011010111
111010101110101111100
011010110110101000111


Output

548356548


Input

3 4
000
101
1111
0010


Output

21


Input

9 13
111100001
010101011
0000000000000
1010111111101


Output

177856


Input

23 30
01010010101010010001110
11010100100100101010101
000101001001010010101010101101
101001000100101001010010101000


Output

734524988
// #pragma GCC target("avx2")  // CPU 処理並列化
// #pragma GCC optimize("O3")  // CPU 処理並列化
// #pragma GCC optimize("unroll-loops")  // 条件処理の呼び出しを減らす
#include<stdio.h>
#include<math.h>
#include<algorithm>
#include<queue>
#include<deque>
#include<stack>
#include<string>
#include<string.h>
#include<vector>
#include<set>
#include<map>
#include<bitset>
#include<stdlib.h>
#include<cassert>
#include<time.h>
#include<bitset>
#include<numeric>
#include<unordered_set>
#include<complex>
using namespace std;
const long long mod=998244353;
const long long inf=mod*mod;
const long long d2=(mod+1)/2;
const double EPS=1e-10;
const double INF=1e+10;
const double PI=acos(-1.0);
const int C_SIZE = 3121000;
namespace{
	long long fact[C_SIZE];
	long long finv[C_SIZE];
	long long inv[C_SIZE];
	long long Comb(int a,int b){
	 	if(a<b||b<0)return 0;
	 	return fact[a]*finv[b]%mod*finv[a-b]%mod;
	}
	void init_C(int n){
		fact[0]=finv[0]=inv[1]=1;
		for(int i=2;i<n;i++){
			inv[i]=(mod-(mod/i)*inv[mod%i]%mod)%mod;
		}
		for(int i=1;i<n;i++){
			fact[i]=fact[i-1]*i%mod;
			finv[i]=finv[i-1]*inv[i]%mod;
		}
	}
	long long pw(long long a,long long b){
		if(a<0LL)return 0;
		if(b<0LL)return 0;
		long long ret=1;
		while(b){
			if(b%2)ret=ret*a%mod;
			a=a*a%mod;
			b/=2;
		}
		return ret;
	}
	long long pw_mod(long long a,long long b,long long M){
		if(a<0LL)return 0;
		if(b<0LL)return 0;
		long long ret=1;
		while(b){
			if(b%2)ret=ret*a%M;
			a=a*a%M;
			b/=2;
		}
		return ret;
	}
	int pw_mod_int(int a,int b,int M){
		if(a<0)return 0;
		if(b<0)return 0;
		int ret=1;
		while(b){
			if(b%2)ret=(long long)ret*a%M;
			a=(long long)a*a%M;
			b/=2;
		}
		return ret;
	}
	int ABS(int a){return max(a,-a);}
	long long ABS(long long a){return max(a,-a);}
	double ABS(double a){return max(a,-a);}
	int sig(double r) { return (r < -EPS) ? -1 : (r > +EPS) ? +1 : 0; }
}
// ここから編集しろ
char A[110000];
char B[110000];
char C[110000];
char D[110000];
long long U[110000];
long long S[110000];
int main(){
	int a,b;scanf("%d%d",&a,&b);
	scanf("%s%s%s%s",A,B,C,D);
	int cnt=0;
	for(int i=0;i<a;i++)cnt+=A[i]-'0';
	for(int i=0;i<a;i++)cnt+=B[i]-'0';
	for(int i=0;i<b;i++)cnt+=C[i]-'0';
	for(int i=0;i<b;i++)cnt+=D[i]-'0';
	if(cnt==0){
		printf("1\n");return 0;
	}
	long long ret=0;
	init_C(410000);
	for(int w=0;w<2;w++){
		int l=0;
		int r=0;
		int uc=0;
		int dc=0;
		for(int i=0;i<b;i++){
			uc+=C[i]-'0';
			dc+=D[i]-'0';
		}
		for(int i=0;i<110000;i++)U[i]=S[i]=0;
		for(int i=0;i<a;i++){
			U[i]=Comb(l+r+uc-1,l+r);
			if(l+r==0)U[i]=1;
			if(A[i]=='1')l++;
			if(B[i]=='1')r++;
		}
		l=0;
		r=0;
		for(int i=0;i<a;i++){
			S[i]=Comb(l+r+dc-1,l+r);
			if(l+r==0)S[i]=1;
			if(A[a-1-i]=='1')l++;
			if(B[a-1-i]=='1')r++;
		}
		// for(int i=0;i<a;i++)printf("%d: %lld %lld\n",i,U[i],S[i]);
		long long ks=0;
		for(int i=0;i<a;i++){
			if(A[i]=='1'||B[i]=='1')ks=(ks+U[i])%mod;
			if(A[i]=='1'&&B[i]=='1')ks=ks*2%mod;
			if(A[i]=='1'||B[i]=='1')ret=(ret+ks*S[a-i-1])%mod;
			// printf("%d: %lld %lld\n",i,ks,S[a-i-1]);
		}
		swap(a,b);
		swap(A,C);
		swap(B,D);
	}
	printf("%lld\n",ret);
}

