#include <bits/stdc++.h>
using namespace std;
long long mod = 998244353;
int frq[200005];
int main() {
  int n, m, i, j;
  string a, b;
  memset(frq, 0, sizeof frq);
  cin >> n >> m >> a >> b;
  for (i = 0; i < m; i++) {
    j = m - i - 1;
    frq[j] = frq[j + 1];
    if (b[i] == '1') frq[j]++;
  }
  long long ans = 0, val = 1;
  for (i = 0; i < n; i++) {
    if (a[n - i - 1] == '1') {
      ans = ans + frq[i] * val;
      ans %= mod;
    }
    val = (val * 2) % mod;
  }
  cout << ans;
  return 0;
}
