#include <bits/stdc++.h>
using namespace std;
int cum[200005];
int main() {
  int n, m;
  scanf("%d %d", &n, &m);
  string a, b;
  cin >> a >> b;
  if (b[0] == '1') cum[0] = 1;
  for (int i = 1; i < m; i++) {
    if (b[i] == '1')
      cum[i] = cum[i - 1] + 1;
    else
      cum[i] = cum[i - 1];
  }
  int long long temp = 1, ans = 0;
  int j = m - 1;
  for (int i = n - 1; i >= 0; i--) {
    if (j < 0) break;
    if (a[i] == '1') {
      ans = (ans % 998244353 +
             ((cum[j] % 998244353) * (temp % 998244353)) % 998244353) %
            998244353;
    }
    temp = (temp % 998244353 * 2) % 998244353;
    j--;
  }
  printf("%lld\n", ans);
  return 0;
}
