#include <bits/stdc++.h>
using namespace std;
const int Z = (int)2e5 + 123;
const int inf = (int)1e9 + 123;
const long long llinf = (long long)1e18 + 123;
const long double pi = acos(-1.0);
const int MOD = (int)998244353;
void norm(string &a, string &b) {
  reverse((b).begin(), b.end());
  while (int(a.size()) > int(b.size())) {
    b += '0';
  }
  reverse((b).begin(), b.end());
}
int pref[Z], st[Z];
int main() {
  ios_base::sync_with_stdio(false);
  int n, m;
  cin >> n >> m;
  string a, b;
  cin >> a >> b;
  norm(b, a);
  norm(a, b);
  st[0] = 1;
  for (int i = 1; i <= Z; i++) {
    st[i] = (st[i - 1] * 2) % MOD;
  }
  if (b[0] == '1') {
    pref[0] = 1;
  }
  for (int i = 1; i < int(b.size()); i++) {
    pref[i] = pref[i - 1];
    if (b[i] == '1') pref[i]++;
  }
  int ans = 0;
  for (int i = 0; i < int(a.size()); i++) {
    if (a[i] == '1') {
      ans = (ans + (1LL * st[int(a.size()) - i - 1] * pref[i]) % MOD) % MOD;
    }
  }
  cout << ans;
  return 0;
}
