#include <bits/stdc++.h>
using namespace std;
long long power(long long a, long long b) {
  long long res = 1;
  a = a % 998244353;
  while (b > 0) {
    if (b & 1) {
      res = (res * a) % 998244353;
      b--;
    }
    a = (a * a) % 998244353;
    b >>= 1;
  }
  return res;
}
long long gcd(long long a, long long b) { return (b == 0) ? a : gcd(b, a % b); }
const long long mxn = 2e5;
void solve() {
  long long n, m;
  cin >> n >> m;
  string a, b;
  cin >> a;
  cin >> b;
  long long pr[m + 1];
  pr[0] = 0;
  for (long long i = 1; i <= m; i++) {
    pr[i] = pr[i - 1];
    if (b[i - 1] == '1') pr[i]++;
  }
  long long ans = 0;
  long long N = m;
  for (long long i = n; (i >= 1 && N >= 1); i--, N--) {
    if (a[i - 1] == '1') {
      ans = (ans + pr[N] * (power(2LL, n - i))) % 998244353;
    }
  }
  cout << ans % 998244353 << '\n';
}
signed main() {
  ios_base::sync_with_stdio(0);
  cin.tie(NULL);
  cout.tie(NULL);
  long long T = 1;
  while (T--) {
    solve();
  }
  return 0;
}
