#include <bits/stdc++.h>
using namespace std;
const int MAXN = 1000005;
const long long mod = 998244353;
int n, m;
char s1[MAXN], s2[MAXN];
long long sum[MAXN], ans;
int main() {
  scanf("%d %d", &n, &m);
  scanf("%s %s", s1, s2);
  for (int i = 0; i < m; ++i) {
    if (i) sum[i] = sum[i - 1];
    sum[i] += (s2[i] == '1');
  }
  int now = m - 1;
  long long base = 1;
  for (int i = n - 1; ~i; --i) {
    if (now == -1) break;
    if (s1[i] == '1') {
      ans = (ans + base * sum[now]) % mod;
    }
    base = base * 2 % mod;
    now--;
  }
  printf("%lld\n", ans);
  return 0;
}
