#include <bits/stdc++.h>
using namespace std;
const int INF = 0x3f3f3f3f;
const int N = 2e5 + 5;
const int mod = 998244353;
long long Pow(long long x, long long n) {
  long long res = 1;
  while (n > 0) {
    if (n % 2 == 1) {
      res = res * x;
      res = res % mod;
    }
    x = x * x;
    x = x % mod;
    n >>= 1;
  }
  return res;
}
int num[N];
char a[N], b[N];
int main() {
  int n, m;
  cin >> n >> m;
  scanf("%s %s", &a, &b);
  int la = strlen(a);
  int lb = strlen(b);
  int l = max(la, lb);
  if (la > lb) {
    for (int i = lb; i < la; i++) {
      b[i] = '0';
    }
  } else {
    for (int i = la; i < lb; i++) {
      a[i] = '0';
    }
  }
  reverse(a, a + la);
  reverse(b, b + lb);
  l = strlen(a);
  for (int i = l - 1; i >= 0; i--) {
    num[i] = num[i + 1] + b[i] - '0';
  }
  long long ans = 0;
  for (int i = 0; i < l; i++) {
    if (a[i] == '1') {
      ans = (ans + Pow(2, i) * num[i] % mod) % mod;
    }
  }
  cout << ans << endl;
  return 0;
}
