#include <bits/stdc++.h>
const double PI = acos(-1);
const double EPS = 1e-12;
const long long MOD = 998244353;
using namespace std;
int main() {
  int a, b;
  char x[200005];
  char y[200005];
  long long suf[200005];
  long long res;
  scanf("%d %d", &a, &b);
  getchar();
  if (a < b) {
    for (int i = 1; i <= b - a; i += 1) {
      x[i] = '0';
    }
    for (int i = 1; i <= a; i += 1) {
      scanf("%c", &x[b - a + i]);
    }
    getchar();
    scanf("%s", y + 1);
  } else if (a > b) {
    scanf("%s", x + 1);
    getchar();
    for (int i = 1; i <= a - b; i += 1) {
      y[i] = '0';
    }
    for (int i = 1; i <= a; i += 1) {
      scanf("%c", &y[a - b + i]);
    }
  } else {
    scanf("%s", x + 1);
    scanf("%s", y + 1);
  }
  int xx = max(a, b);
  long long mul = 1;
  suf[xx + 1] = 0;
  for (int i = xx; i >= 1; i--) {
    mul %= MOD;
    if (x[i] == '1')
      suf[i] = suf[i + 1] + mul;
    else
      suf[i] = suf[i + 1];
    mul *= 2;
  }
  res = 0;
  for (int i = 1; i <= xx; i += 1) {
    if (y[i] == '1') {
      res += suf[i];
    }
    res %= MOD;
  }
  printf("%lld\n", res % MOD);
  return 0;
}
