#include <bits/stdc++.h>

using namespace std;
#define PB push_back
#define MP make_pair
#define LL long long
#define int LL
#define FOR(i,a,b) for(int i = (a); i <= (b); i++)
#define RE(i,n) FOR(i,1,n)
#define REP(i,n) FOR(i,0,(int)(n)-1)
#define R(i,n) REP(i,n)
#define VI vector<int>
#define PII pair<int,int>
#define LD long double
#define FI first
#define SE second
#define st FI
#define nd SE
#define ALL(x) (x).begin(), (x).end()
#define SZ(x) ((int)(x).size())

template<class C> void mini(C &a4, C b4) { a4 = min(a4, b4); }
template<class C> void maxi(C &a4, C b4) { a4 = max(a4, b4); }

template<class TH> void _dbg(const char *sdbg, TH h){ cerr<<sdbg<<'='<<h<<endl; }
template<class TH, class... TA> void _dbg(const char *sdbg, TH h, TA... a) {
  while(*sdbg!=',')cerr<<*sdbg++;cerr<<'='<<h<<','; _dbg(sdbg+1, a...);
}

template<class T> ostream &operator<<(ostream& os, vector<T> V) {
  os << "["; for (auto vv : V) os << vv << ","; return os << "]";
}
template<class L, class R> ostream &operator<<(ostream &os, pair<L,R> P) {
  return os << "(" << P.st << "," << P.nd << ")";
}

#ifdef LOCAL
#define debug(...) _dbg(#__VA_ARGS__, __VA_ARGS__)
#else
#define debug(...) (__VA_ARGS__)
#define cerr if(0)cout
#endif


void pob(vector<int>& res){
  string z;
  cin >> z; 
  R(i,SZ(z)){
    if(z[i] == '1'){
      res.PB(1);
    }else
      res.PB(0);
  }
}

int jed(vector<int>& x){
  int res = 0;
  for(int el:x){
    res += el;
  }
  return res;
}

const int P = 998244353;
const int MAX = 4e5 + 10;
int sil[MAX],od[MAX];
int pot(int a,int w){
  int r = 1;
  while(w){
    if(w & 1){
      r = r * a % P;
    }
    a = a * a % P;
    w/=2;
  }
  return r;
}
int dwu(int a,int b){
 // debug(a,b, sil[a], od[b], od[a-b]);
  return sil[a] * od[b] % P * od[a-b] % P;
}

vector<int> licz2(vector<int>&a,vector<int>& b,int x){
  //TODO x = 0
  int n = SZ(a);
  vector<int> res;
  int il = 0;
//   bool cza = 0;
//   bool czb = 0;
  bool cz = 0;
  R(i,n){
    if(a[i] == 0 && b[i] == 0)
      res.PB(0);
    else{
      if(x == 0){
        if(!cz){
          res.PB(1);
        }else
          res.PB(0);
        cz = 1;
      }else
        res.PB(dwu(x + il - 1, x-1));
    }
//     if(a[i])cza = 1;
//     if(b[i])czb = 1;
    il += a[i];
    il += b[i];
  }
  return res;
}

int licz(vector<int> a,vector<int> b,int x1,int x2){
  int n = SZ(a);
  vector<int> res1 = licz2(a,b,x1);
  reverse(ALL(a));
  reverse(ALL(b));
  reverse(ALL(res1));
  vector<int> res2 = licz2(a,b,x2);
  debug(a,b,x1,x2,res1,res2);
  int pom = 0;
  int res = 0;
  R(i,n){
    pom += res2[i];
    if(a[i] && b[i])pom *= 2;
    pom %= P;
    res += pom * res1[i];
    res %= P;
  }
  return res;
}
int32_t main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout << fixed << setprecision(11);
  cerr << fixed << setprecision(6);
  sil[0] = 1;
  R(i,MAX-1){
    sil[i+1] = sil[i] * (i + 1) % P;
  }
  R(i,MAX){
    od[i] = pot(sil[i], P-2);
  }
  
  
  int n,m;
  vector<int> a,b,c,d;
  cin >> n >> m;
  pob(a);
  pob(b);
  pob(c);
  pob(d);
  int res = licz(a,b,jed(c),jed(d));
  res += licz(c,d,jed(a),jed(b));
  if(jed(a) == 0 && jed(b) == 0 && jed(c) == 0 && jed(d) == 0){
    res = 1;
  }
  cout << res % P << "\n";
}


Measured memory_bytes: 13864