#include <bits/stdc++.h>
using namespace std;
template <class T>
inline bool MX(T &l, const T &r) {
  return l < r ? l = r, 1 : 0;
}
template <class T>
inline bool MN(T &l, const T &r) {
  return l > r ? l = r, 1 : 0;
}
const double EPS = 1e-8;
const int INF = 0x3f3f3f3f;
const int MOD = 998244353;
const int MAXN = (int)2e5 + 5;
char a[MAXN], b[MAXN];
string aa, bb;
vector<int> z(MAXN);
int main() {
  int n, m, ans = 0;
  cin >> n >> m >> aa >> bb;
  reverse(aa.begin(), aa.end());
  reverse(bb.begin(), bb.end());
  strcpy(a, aa.c_str());
  strcpy(b, bb.c_str());
  int N = max(n, m), s = 1;
  for (int i = 0; i < N; i++) {
    z[i] = a[i] == '1' ? s : 0;
    z[i] = (z[i] + (i > 0 ? z[i - 1] : 0)) % MOD;
    s <<= 1;
    s %= MOD;
  }
  for (int i = 0; i < m; i++) {
    ans += b[i] == '1' ? z[i] : 0;
    ans %= MOD;
  }
  cout << ans << endl;
  return 0;
}
