#include <bits/stdc++.h>
using namespace std;
const int MAXN = 2e5 + 10;
const int MOD = 998244353;
int cnt[MAXN];
int cnt2[MAXN];
int main() {
  int n, m;
  scanf("%d%d", &n, &m);
  string s1, s2;
  cin >> s1 >> s2;
  for (int i = 0; i < s2.length(); i++) {
    if (s2[i] == '1') {
      cnt[i]++;
    }
    if (i != 0) cnt[i] += cnt[i - 1];
  }
  for (int i = 0; i < s2.length(); i++) {
    cnt2[s2.length() - i - 1] = cnt[i];
  }
  long long now;
  long long ans = 0;
  for (int i = 0; i < s1.length(); i++) {
    if (i == 0) {
      now = 1;
    } else {
      now = now * 2 % MOD;
    }
    if (s1[s1.length() - 1 - i] == '1') {
      ans += (cnt2[i] * now) % MOD;
      ans %= MOD;
    }
  }
  printf("%I64d", ans);
  return 0;
}
