#include <bits/stdc++.h>
using namespace std;
const long long mod = 998244353;
void run(istream &cin, ostream &cout) {
  int n, m;
  cin >> n >> m;
  string a, b;
  cin >> a >> b;
  int diff = n - m;
  if (diff > 0) {
    b = string(diff, '0') + b;
  } else {
    a = string(-diff, '0') + a;
  }
  n = max(n, m);
  vector<long long> suff(n);
  for (int i = 0; i < n; i++) {
    suff[i] = (b[i] == '1');
    if (i > 0) {
      suff[i] += suff[i - 1];
    }
  }
  long long pw = 1, ans = 0;
  for (int i = n - 1; i >= 0; i--) {
    if (a[i] == '1') {
      ans = (ans + pw * suff[i] % mod) % mod;
    }
    pw = pw * 2 % mod;
  }
  cout << ans;
}
int main() {
  cin.tie(0);
  ios::sync_with_stdio(0);
  run(cin, cout);
  return 0;
}
