#include <bits/stdc++.h>
using namespace std;
long long mod = 998244353;
vector<long long> pow2;
void init() {
  pow2.push_back(1);
  for (int i = 1; i <= 1000000; i++) {
    pow2.push_back((pow2[i - 1] * 2) % mod);
  }
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  init();
  long long n, m;
  cin >> n >> m;
  string a, b;
  cin >> a >> b;
  if (n < m) {
    for (int i = 0; i < (m - n); i++) {
      a = '0' + a;
    }
  } else if (m < n) {
    for (int i = 0; i < (n - m); i++) {
      b = '0' + b;
    }
  }
  n = m = a.length();
  vector<long long> c(m, 0), ans(m, 0);
  if (b[0] == '1') c[0] = 1;
  for (int i = 1; i < m; i++) {
    if (b[i] == '1')
      c[i] = c[i - 1] + 1;
    else
      c[i] = c[i - 1];
  }
  for (int i = 0; i < n; i++) {
    if (a[i] == '0') continue;
    ans[i] = c[i];
  }
  long long f_ans = 0, carry = 0, idx = 0;
  for (int i = m - 1; i >= 0; i--, idx++) {
    long long har = 0;
    ans[i] += carry;
    if (ans[i] % 2 != 0) {
      har = 1;
    }
    carry = (ans[i] / 2);
    if (har) f_ans = (f_ans + pow2[(idx)]) % mod;
  }
  if (carry > 0) {
    while (carry > 0) {
      long long har = 0;
      if (carry % 2 != 0) har = 1;
      carry = (carry / 2);
      if (har) f_ans = (f_ans + pow2[(idx)]) % mod;
      idx++;
    }
  }
  cout << f_ans;
  return 0;
}
