#include <bits/stdc++.h>
const int mod = 998244353;
using namespace std;
long long gcd(long long a, long long b) {
  if (a == 0) return b;
  return gcd(b % a, a);
}
long long lcm(long long a, long long b) { return (a * b) / gcd(a, b); }
long long power(long long x, long long y) {
  long long res = 1;
  while (y > 0) {
    if (y & 1) res = res * x;
    y = y >> 1;
    x = x * x;
  }
  return res;
}
long long pwr(long long a, long long b) {
  if (b == 0) {
    return 1;
  }
  long long p = pwr(a, b / 2);
  p = (p * p) % mod;
  if (b % 2 != 0) {
    p = (p * a) % mod;
  }
  return p;
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  long long n, m;
  cin >> n >> m;
  string a, b;
  cin >> a >> b;
  reverse(a.begin(), a.end());
  reverse(b.begin(), b.end());
  while (m > n) {
    a += "0";
    n++;
  }
  while (n > m) {
    b += "0";
    m++;
  }
  reverse(a.begin(), a.end());
  reverse(b.begin(), b.end());
  long long ans = 0;
  long long settillnow = 0;
  for (long long i = 0; i < n; i++) {
    if (b[i] == '1') {
      settillnow++;
    }
    if (a[i] == '1') {
      long long c = pwr(2, n - 1 - i);
      c = (c * settillnow) % mod;
      ans += c;
      ans %= mod;
    }
  }
  cout << ans << endl;
}
