#include <bits/stdc++.h>
using namespace std;
long long int n, m;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  string a, b;
  cin >> n >> m;
  cin >> a >> b;
  long long int mx = max(n, m);
  for (int i = 0; i < mx - n; i++) {
    a = "0" + a;
  }
  for (int i = 0; i < mx - m; i++) {
    b = "0" + b;
  }
  long long int setbits[mx];
  if (b[0] == '1')
    setbits[0] = 1;
  else
    setbits[0] = 0;
  for (int i = 1; i < mx; i++) {
    setbits[i] = setbits[i - 1];
    if (b[i] == '1') setbits[i]++;
  }
  long long int pw = 1, ans = 0;
  for (long long int i = mx - 1; i >= 0; i--) {
    if (a[i] == '1') {
      ans = ((ans % 998244353) + (setbits[i] * pw) % 998244353) % 998244353;
    }
    pw = (pw << 1) % 998244353;
  }
  cout << ans << endl;
  return 0;
}
