#include <bits/stdc++.h>
using namespace std;
int main() {
  string a, b;
  int n, m;
  cin >> n >> m;
  cin >> a >> b;
  int pw = 1;
  int ans = 0, res = 0;
  for (int i = 0; i < m; i++) {
    if (i < n && a[n - i - 1] == '1') res = (res + pw) % 998244353;
    if (b[m - i - 1] == '1') ans = (ans + res) % 998244353;
    pw = (pw + pw) % 998244353;
  }
  cout << ans << endl;
  return 0;
}
