#include <bits/stdc++.h>
using namespace std;
string a;
string b;
int n;
int m;
long long d[500005];
long long quick_pow(long long x, long long n) {
  long long ret = 1LL;
  while (n) {
    if (n & 1) ret = ret * x % 998244353;
    x = x * x % 998244353;
    n >>= 1;
  }
  return ret;
}
int main() {
  cin >> n >> m;
  cin >> a >> b;
  reverse(a.begin(), a.end());
  reverse(b.begin(), b.end());
  for (int i = 0; i < m; ++i) {
    if (b[i] == '1') {
      ++d[0];
      --d[i + 1];
    }
  }
  for (int i = 1; i < n; ++i) d[i] += d[i - 1];
  long long ans = 0;
  for (int i = 0; i < n; ++i)
    if (a[i] == '1') ans = (ans + quick_pow(2LL, 1LL * i) * d[i]) % 998244353;
  printf("%lld\n", ans);
  return 0;
}
