#include <bits/stdc++.h>
using namespace std;
template <typename T>
void out(T x) {
  cout << x << endl;
  exit(0);
}
const int maxn = 1e6 + 7;
const long long modder = 998244353;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  int lena, lenb;
  cin >> lena >> lenb;
  string a, b;
  cin >> a >> b;
  vector<long long> pref(lenb);
  for (int i = 0; i < lenb; i++) {
    if (i - 1 >= 0) pref[i] += pref[i - 1];
    if (b[i] == '1') pref[i]++;
  }
  reverse(pref.begin(), pref.end());
  vector<long long> pows2(lena + 1);
  long long cur = 1LL;
  pows2[0] = cur;
  for (int i = 1; i <= lena; i++) {
    cur *= 2LL;
    cur %= modder;
    pows2[i] = cur;
  }
  long long ans = 0LL;
  reverse(a.begin(), a.end());
  for (int i = 0; i < min(lena, lenb); i++) {
    if (a[i] == '0') continue;
    long long val = pref[i] * pows2[i];
    val %= modder;
    ans += val;
    ans %= modder;
  }
  out(ans);
  return 0;
}
