#include <bits/stdc++.h>
using namespace std;
int i, j, k;
int n, m, pow2[200010], cnt[200010], ans;
string s1, s2;
void code() {
  cin >> n >> m;
  cin >> s1 >> s2;
  pow2[0] = 1;
  for (i = 1; i < 200010; i++) pow2[i] = (pow2[i - 1] * 2LL) % 998244353;
  reverse((s1).begin(), (s1).end());
  reverse((s2).begin(), (s2).end());
  for (i = m - 1; i > -1; i--) cnt[i] = cnt[i + 1] + (s2[i] == '1');
  for (i = n - 1; i > -2; i--)
    ans = (ans * 1LL + ((s1[i] == '1') * 1LL * pow2[i] * cnt[i]) % 998244353) %
          998244353;
  cout << ans << '\n';
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  int t = 1;
  while (t--) {
    code();
  }
}
