#include <bits/stdc++.h>
using namespace std;
const int N = int(2e5) + 10;
const int MOD = 998244353;
int a[N], b[N];
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  for (int i = 0; i < N; i++) {
    a[i] = 0;
    b[i] = 0;
  }
  int n, m;
  cin >> n >> m;
  string p, q;
  cin >> p >> q;
  int l = max(n, m);
  for (int i = max(0, l - n); i < l; i++) {
    a[i] = p[i - max(0, l - n)] - '0';
  }
  for (int i = max(0, l - m); i < l; i++) {
    b[i] = q[i - max(0, l - m)] - '0';
  }
  long long ans = 0, currNum = 1, tempSum = 0;
  for (int i = l - 1; i >= 0; i--) {
    if (a[i]) {
      tempSum += currNum;
      tempSum = tempSum % MOD;
    }
    if (b[i]) {
      ans += tempSum;
      ans = ans % MOD;
    }
    currNum = (2 * currNum) % MOD;
  }
  cout << ans % MOD << endl;
  return 0;
}
