#include <bits/stdc++.h>
#pragma comment(linker, "/STACK:1024000000,1024000000")
using namespace std;
const long long mod = 998244353;
const int maxn = 1e6 + 10;
char a[maxn], b[maxn];
char s1[maxn], s2[maxn];
int fastpow(int base, int power) {
  if (!power) return 1;
  int ret = fastpow(base, power / 2);
  ret = (ret * 1ll * ret) % mod;
  if (power & 1) ret = (ret * 1ll * base) % mod;
  return ret;
}
int main() {
  int n, m;
  cin >> n >> m;
  for (int i = n - 1; i >= 0; --i) cin >> s1[i];
  for (int i = m - 1; i >= 0; --i) cin >> s2[i];
  int have = 0;
  for (int i = 0; i < m; i++) have += (s2[i] == '1');
  int idx = 0;
  int ans = 0;
  for (int j = 0, z = 0; j < n && have; ++j, ++z) {
    if (s1[j] == '1') ans = (ans + (fastpow(2, idx) * 1ll * have) % mod) % mod;
    if (s2[z] == '1') have--;
    idx++;
  }
  cout << ans << endl;
}
