#include <bits/stdc++.h>
using namespace std;
int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int n, m;
  cin >> n >> m;
  string a, b;
  cin >> a >> b;
  reverse(a.begin(), a.end());
  reverse(b.begin(), b.end());
  int k = min(n, m);
  long long now = 0, power2 = 1;
  long long sum = 0;
  for (int i = 0; i < k; i++) {
    now = (power2 * (a[i] - '0') + now) % 998244353;
    power2 = (power2 * 2) % 998244353;
    sum = (now * (b[i] - '0') + sum) % 998244353;
  }
  for (int i = k; i < m; i++) {
    sum = (now * (b[i] - '0') + sum) % 998244353;
  }
  cout << sum;
  return 0;
}
