#include <bits/stdc++.h>
using namespace std;
const int mod = 998244353, N = 2e5 + 10;
long long bin_expo(long long x, long long y, long long m) {
  long long res = 1;
  x = x % m;
  while (y > 0) {
    if (y & 1) res = (res * x) % m;
    y = y / 2;
    x = (x * x) % m;
  }
  return res;
}
void solve() {
  long long n, m;
  cin >> n >> m;
  string s1, s2;
  cin >> s1 >> s2;
  long long c[N] = {0};
  for (int i = max((long long)0, n - m); i < m + max((long long)0, n - m);
       i++) {
    if (i == max((long long)0, n - m)) {
      if (s2[i - max((long long)0, n - m)] == '0')
        c[i] = 0;
      else
        c[i] = 1;
    } else {
      if (s2[i - max((long long)0, n - m)] == '0')
        c[i] = c[i - 1];
      else
        c[i] = c[i - 1] + 1;
    }
  }
  long long ans = 0;
  for (int i = 0; i < n; i++) {
    if (s1[i] == '1') {
      if (m > n)
        ans = ans + bin_expo(2, n - 1 - i, mod) * c[i + m - n];
      else
        ans = ans + bin_expo(2, n - 1 - i, mod) * c[i];
      ans = ans % mod;
    }
  }
  cout << ans << "\n";
  return;
}
int32_t main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  int test = 1;
  while (test--) {
    solve();
  }
}
