#include <bits/stdc++.h>
using namespace std;
long long Bmod(long long a, long long b, long long c) {
  if (b == 0) return 1;
  if (b % 2 == 0) {
    long long x = Bmod(a, b / 2, c);
    return (x % c * x % c) % c;
  } else
    return (a % c * Bmod(a, b - 1, c)) % c;
}
long long sum[200005];
int main() {
  int n, m;
  cin >> n >> m;
  string a, b;
  cin >> a >> b;
  reverse(a.begin(), a.end());
  reverse(b.begin(), b.end());
  vector<int> A;
  int k = 0;
  long long int ans = 0;
  for (int i = 0; i < n; i++) {
    if (a[i] == '1') {
      sum[k] = Bmod(2LL, (long long)i, 998244353) + (k == 0 ? 0LL : sum[k - 1]);
      k++;
      A.push_back(i);
    }
  }
  for (int i = 0; i < m; i++) {
    if (b[i] == '1') {
      int l = lower_bound(A.begin(), A.end(), i) - A.begin();
      if (l == A.size())
        l = l - 1;
      else
        l = l - (A[l] > i);
      ans = (ans % 998244353 + sum[l] % 998244353) % 998244353;
    }
  }
  cout << ans;
  return 0;
}
