#include <bits/stdc++.h>
using namespace std;
int i, j, k, z, q, timer, x, y, n, m, cnt, even, flag, dlfjl, dskgj, dkfj,
    dskfj, boom, r, c;
vector<pair<int, int> > f, f1;
int a[1000500], b[1005000];
int main() {
  int n, m;
  cin >> n >> m;
  string s, t;
  cin >> s >> t;
  a[n - 1] = s[n - 1] - '0';
  int p = 1;
  for (int i = n - 2; i >= 0; i--) {
    p = p * 2 % 998244353;
    a[i] = (a[i + 1] + p * (s[i] - '0')) % 998244353;
  }
  int pos = n - 1;
  int ans = 0;
  for (int i = m - 1; i >= 0; i--) {
    ans = (ans + (t[i] - '0') * a[pos]) % 998244353;
    pos--;
    if (pos < 0) pos = 0;
  }
  cout << ans << endl;
  return 0;
}
