#include <bits/stdc++.h>
using namespace std;
long long bigMod(long long a, long long b) {
  if (b == 0)
    return 1;
  else {
    long long temp = bigMod(a, b / 2);
    temp = (temp * temp) % 998244353;
    if (b % 2 == 1) temp = (temp * a) % 998244353;
    return temp;
  }
}
int main() {
  ios_base::sync_with_stdio(false);
  int n, m;
  cin >> n >> m;
  string a, b, s = "";
  cin >> a;
  cin >> b;
  if (n < m) {
    int d = m - n;
    for (int i = 0; i < d; ++i) {
      s.push_back('0');
    }
    a = s + a;
    n = m;
  } else {
    int d = n - m;
    for (int i = 0; i < d; ++i) {
      s.push_back('0');
    }
    b = s + b;
    m = n;
  }
  long long total = 0, t1, counter = 0;
  for (int i = 0; i < n; ++i) {
    if (b[i] == '1') ++counter;
    if (a[i] == '1' && counter > 0) {
      t1 = bigMod(2, n - i - 1);
      t1 = (t1 * counter) % 998244353;
      total = (total + t1) % 998244353;
    }
  }
  cout << total << endl;
  return 0;
}
