#include <bits/stdc++.h>
using namespace std;
int gcd(int a, int b) { return b ? gcd(b, a % b) : a; }
int lcm(int a, int b) { return a / gcd(a, b) * b; }
long long powmod(long long a, long long b, long long MOD) {
  long long ans = 1;
  while (b) {
    if (b % 2) ans = ans * a % MOD;
    a = a * a % MOD;
    b /= 2;
  }
  return ans;
}
const int maxn = 2e5 + 10;
int n, m, pos;
long long sum[maxn], la = 0, ans, fs[maxn + 1];
char a[maxn + 1], b[maxn + 1];
int main() {
  scanf("%d%d", &n, &m);
  scanf("%s %s", a, b);
  for (int i = 0; i < m; i++) sum[i] = la + (b[i] == '1'), la = sum[i];
  int fa = m - 1;
  for (int i = n - 1; i >= 0 && fa >= 0; i--) fs[i] = sum[fa--];
  for (int i = 0; i < n; i++) {
    if (a[i] == '0')
      continue;
    else
      ans = (ans + fs[i] * powmod(2, n - i - 1, 998244353) % 998244353) %
            998244353;
  }
  printf("%lld\n", ans);
  return 0;
}
