#include <bits/stdc++.h>
using namespace std;
using ll = long long;
void debug() { cerr << "]\n"; }
template <class H, class... T>
void debug(H h, T... t) {
  cerr << h;
  if (sizeof...(t)) {
    cerr << ", ";
  }
  debug(t...);
}
mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count());
const long long mod = 998244353;
long long bpow(long long a, long long b) {
  long long res = 1;
  while (b) {
    if (b & 1) {
      res = (res * a) % mod;
    }
    a = (a * a) % mod;
    b >>= 1;
  }
  return res;
}
void solve() {
  int n, m;
  cin >> n >> m;
  string a;
  cin >> a;
  string b;
  cin >> b;
  reverse(a.begin(), a.end());
  reverse(b.begin(), b.end());
  long long now = 0;
  long long ans = 0;
  for (int i = 0; i < min(m, n); i++) {
    if (a[i] == '1') {
      now += bpow(2, i);
      now %= mod;
    }
    if (b[i] == '1') {
      ans += now;
      ans %= mod;
    }
  }
  long long cnt = 0;
  for (int i = min(m, n); i < m; i++) {
    cnt += (b[i] == '1');
  }
  ans += (now * cnt) % mod;
  ans %= mod;
  cout << ans << "\n";
}
int32_t main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  int _;
  _ = 1;
  for (int i = 1; i <= _; i++) {
    solve();
  }
  return 0;
}
