#include <bits/stdc++.h>
using namespace std;
const int mod = 998244353;
const int maxn = 2e5 + 5;
int n, m;
char a[maxn], b[maxn];
long long sumb1[maxn];
long long Q_pow(long long a, long long n) {
  long long res = 1;
  while (n) {
    if (n & 1) res = res * a % mod;
    a = a * a % mod;
    n >>= 1;
  }
  return res;
}
int main() {
  while (scanf("%d%d", &n, &m) != EOF) {
    scanf("%s%s", a + 1, b + 1);
    memset(sumb1, 0, sizeof sumb1);
    for (int i = 1; i <= m; i++) {
      if (b[i] == '1') {
        sumb1[i] = sumb1[i - 1] + 1;
      } else
        sumb1[i] = sumb1[i - 1];
    }
    long long ans = 0;
    for (int i = n, j = m; i > 0 && j > 0; i--, j--) {
      if (a[i] == '1') {
        ans = (ans + Q_pow(2, n - i) * sumb1[j] % mod) % mod;
      }
    }
    printf("%lld\n", ans);
  }
  return 0;
}
