#include <bits/stdc++.h>
using namespace std;
void solve() {
  long long n, m;
  cin >> n >> m;
  string a, b;
  cin >> a >> b;
  reverse(a.begin(), a.end());
  reverse(b.begin(), b.end());
  vector<long long> v(n, 0), u(m, 0);
  for (long long i = 0; i < n; i++) {
    if (a[i] == '1') {
      v[i] = 1;
    }
  }
  for (long long i = 0; i < m; i++) {
    if (b[i] == '1') {
      u[i] = 1;
    }
  }
  for (long long i = m - 2; i >= 0; i--) {
    u[i] += u[i + 1];
  }
  map<long long, long long> mp;
  mp[0] = 1;
  for (long long i = 1; i < 2 * pow(10, 5) + 4; i++) {
    mp[i] = mp[i - 1] * 2 % 998244353;
  }
  long long ans = 0;
  for (long long i = 0; i < min(v.size(), u.size()); i++) {
    if (v[i] == 1) {
      long long x = (mp[i] % 998244353 * u[i] % 998244353) % 998244353;
      ans = (ans + x) % 998244353;
    }
  }
  cout << ans << endl;
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  ;
  long long test = 1;
  while (test--) solve();
}
