#include <bits/stdc++.h>
using namespace std;
const int N = 3e5 + 5;
const long long M = 998244353;
long long power(long long x, long long y) {
  x %= M;
  long long ans = 1;
  while (y) {
    if (y & 1) ans = (ans * x) % M;
    y >>= 1LL;
    x = (x * x) % M;
  }
  return ans;
}
long long ad(long long a, long long b) { return ((a % M + b % M) % M); }
long long mul(long long a, long long b) { return (((a % M) * (b % M)) % M); }
long long a[N];
int main() {
  ios_base ::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  int n, m;
  cin >> n >> m;
  string s, t;
  cin >> s >> t;
  long long diff = m - n;
  for (int i = 0; i < m; i++) {
    if (t[i] == '1') {
      a[max(0LL, i - diff)]++, a[n + 1]--;
    }
  }
  for (int i = 1; i < N; i++) a[i] += a[i - 1];
  long long ans = 0;
  for (int i = 0; i < n; i++) {
    if (s[i] == '0') continue;
    long long yo = n - i - 1;
    ans = ad(ans, mul(a[i], power(2, yo)));
  }
  cout << ans;
  return 0;
}
