#include <bits/stdc++.h>
using namespace std;
const int NUM = 2e5 + 5;
const int mod = 998244353;
int INF = 1e6;
pair<int, int> pinf = {INF, INF};
long long bin_pow(int n) {
  if (n == 0) return 1;
  if (n % 2 == 0) return bin_pow(n / 2) * bin_pow(n / 2) % mod;
  return 2 * bin_pow(n - 1) % mod;
}
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(NULL);
  int n, m;
  cin >> m >> n;
  string a, b;
  cin >> b;
  cin >> a;
  reverse(a.begin(), a.end());
  reverse(b.begin(), b.end());
  long long s[m];
  s[0] = (b[0] - '0');
  for (int i = 1; i < m; i++) {
    s[i] = s[i - 1];
    if (b[i] == '1') s[i] += bin_pow(i);
    s[i] %= mod;
  }
  long long ans = 0;
  for (int i = 0; i < n; i++) {
    if (a[i] == '1') ans += s[min(i, m - 1)];
    ans %= mod;
  }
  cout << ans;
  return 0;
}
