#include <bits/stdc++.h>
using namespace std;
inline void prep() {
  cin.tie(0);
  cin.sync_with_stdio(0);
};
const int mod = 998244353;
const int MX = (int)2e5 + 10;
int main() {
  prep();
  int n, m;
  cin >> n >> m;
  string a, b;
  cin >> a >> b;
  reverse(a.begin(), a.end());
  reverse(b.begin(), b.end());
  int cnt = count(b.begin(), b.end(), '1');
  long long res = 0;
  int p = 1;
  for (int i = 0; i < n; ++i) {
    if (a[i] == '1') res = (res + p * 1ll * cnt) % mod;
    if (cnt > 0 && b[i] == '1') cnt--;
    p = p * 2 % mod;
  }
  cout << res % mod << '\n';
  return 0;
}
