#include <bits/stdc++.h>
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
using namespace std;
const int mod = 998244353;
long long pow2(int x) {
  if (!x) return 1;
  if (x & 1) return (2 * pow2(x - 1)) % mod;
  long long a = pow2(x >> 1);
  return (a * a) % mod;
}
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  int n, m;
  string s, t;
  cin >> n >> m >> s >> t;
  vector<int> x(n);
  int ye = 0;
  for (int i = 0; i < m; ++i) {
    if (t[i] == '1') ++ye;
    if (i + n - m < 0) continue;
    if (s[i + n - m] == '1') x[m - i - 1] = ye;
  }
  long long res = 0;
  for (int i = 0; i < n; ++i) res = (res + (x[i] * pow2(i)) % mod) % mod;
  printf("%lld\n", res);
}
