#include <bits/stdc++.h>
using namespace std;
long long N, M, pref[(int)3e5 + 3];
string second, t;
long long power(long long a, long long b) {
  long long x = 1, y = a;
  while (b > 0) {
    if (b % 2 == 1) {
      x = (x * y);
      if (x > 998244353) x %= 998244353;
    }
    y = (y * y);
    if (y > 998244353) y %= 998244353;
    b /= 2;
  }
  return x;
}
long long ans;
int main() {
  ios::sync_with_stdio(false);
  cin >> N >> M;
  cin >> second >> t;
  reverse(second.begin(), second.end());
  reverse(t.begin(), t.end());
  for (int i = t.size() - 1; i >= 0; i--) {
    pref[i] += pref[i + 1];
    if (t[i] == '1') pref[i]++;
  }
  int c = 0;
  for (int i = 0; i < second.size(); i++) {
    if (second[i] == '1') {
      long long pls = pref[i] * power(2, i);
      pls %= 998244353;
      ans += pls;
      ans %= 998244353;
    }
  }
  cout << ans;
  return 0;
}
