#include <bits/stdc++.h>
using namespace std;
long long int mod = 998244353;
int main() {
  int n, m;
  cin >> n >> m;
  long long int p = 1;
  string a, b;
  cin >> a >> b;
  long long int cum[max(n, m) + 5];
  memset(cum, 0, sizeof(cum));
  while (n > m) {
    b = "0" + b;
    ++m;
  }
  while (m > n) {
    a = "0" + a;
    ++n;
  }
  for (int i = 0; i < m; ++i) {
    if (b[i] == '1') cum[i] = 1;
    if (i) {
      cum[i] += cum[i - 1];
    }
  }
  long long int ans = 0;
  for (int i = n - 1; i >= 0; --i) {
    if (a[i] == '1') {
      long long int temp = ((p % mod) * (cum[i] % mod)) % mod;
      ans = ((ans % mod) + (temp % mod)) % mod;
    }
    p = ((p % mod) * 2) % mod;
  }
  cout << ans;
  return 0;
}
