#include <bits/stdc++.h>
using namespace std;
int32_t main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  ;
  string a, b;
  long long N, M, resp = 0, sum = 0, x = 1;
  cin >> N >> M;
  cin >> a >> b;
  for (long long i = 0; i < M; i++) {
    if (a[N - 1 - i] == '1' && i < N) {
      sum = (sum + x) % 998244353;
    }
    if (b[M - 1 - i] == '1') {
      resp = (resp + sum) % 998244353;
    }
    x = (x * 2) % 998244353;
  }
  cout << resp << "\n";
}
