#include <bits/stdc++.h>
using namespace std;
const int mod = 998244353;
char a[200005];
char b[200005];
int aa[200005];
int bb[200005];
long long qmod(long long a, long long b) {
  long long res = 1;
  while (b) {
    if (b & 1) res = res * a % mod;
    a = a * a % mod;
    b = b >> 1;
  }
  return res;
}
int main() {
  int n, m;
  scanf("%d %d", &n, &m);
  getchar();
  for (int i = 1; i <= n; i++) scanf("%c", &a[i]);
  getchar();
  for (int i = 1; i <= m; i++) scanf("%c", &b[i]);
  if (n > m) {
    for (int i = n; i > n - m; i--) b[i] = b[i + m - n];
    for (int i = 1; i <= n - m; i++) b[i] = '0';
  } else {
    for (int i = m; i > m - n; i--) a[i] = a[i + n - m];
    for (int i = 1; i <= m - n; i++) a[i] = '0';
  }
  int mx = max(m, n);
  bb[0] = 0;
  for (int i = 1; i <= mx; i++) aa[i] = a[mx - i + 1] - '0';
  for (int i = 1; i <= mx; i++) bb[i] = b[mx - i + 1] - '0';
  for (int i = 1; i <= mx; i++) bb[i] = bb[i] + bb[i - 1];
  long long ans = 0;
  for (int i = 1; i <= mx; i++)
    if (aa[i] == 1)
      (ans += qmod(2, i - 1) * (bb[mx] - bb[i - 1] + mod) % mod) %= mod;
  printf("%I64d\n", ans);
}
