#include <bits/stdc++.h>
using namespace std;
long long bin_pow(long long p, long long st) {
  if (st == 0) return 1;
  if (st % 2)
    return (p * bin_pow(p, st - 1)) % 998244353ll;
  else {
    long long b = bin_pow(p, st / 2);
    return (b * b) % 998244353ll;
  }
}
inline void solve() {
  int n, m;
  cin >> n >> m;
  string s, t;
  cin >> s >> t;
  long long otv = 0;
  while (s.size() < t.size()) s = '0' + s;
  while (s.size() > t.size()) t = '0' + t;
  vector<long long> pref(t.size(), 0);
  pref[0] = t[0] - '0';
  for (int i = 1; i < (t.size()); i++) pref[i] = pref[i - 1] + (t[i] - '0');
  for (int i = 0; i < (t.size()); i++) {
    if (s[i] == '1')
      otv += (pref[i] * bin_pow(2ll, t.size() - i - 1)) % 998244353ll;
    otv %= 998244353ll;
  }
  cout << otv;
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  solve();
}
