#include <bits/stdc++.h>
using namespace std;
const int MAX = 2e5 + 5;
const int MOD = 998244353;
long long p[MAX];
long long mpow[MAX];
int main(int argc, char* argv[]) {
  if (argc == 2 or argc == 3) freopen(argv[1], "r", stdin);
  if (argc == 3) freopen(argv[2], "w", stdout);
  int n, m;
  string a, b;
  cin >> n >> m >> a >> b;
  while (n < m) a = "0" + a, n++;
  while (m < n) b = "0" + b, m++;
  mpow[0] = 1;
  for (int i = 1; i < MAX; i++) {
    mpow[i] = (mpow[i - 1] * 2) % MOD;
  }
  for (int i = n - 1; i >= 0; i--) {
    p[i] = p[i + 1] + (a[i] == '1') * mpow[n - i - 1];
    p[i] %= MOD;
  }
  long long ans = 0;
  for (int i = 0; i < m; i++) {
    if (b[i] == '1') {
      ans = (ans + p[i]) % MOD;
    }
  }
  cout << ans << endl;
  return 0;
}
