#include <bits/stdc++.h>
using namespace std;
const long long N = 2e5 + 5;
long long MOD = (long long)(998244353);
long long power(long long a, long long b) {
  if (b == 0) return 1;
  if (b == 1) return a;
  if (b % 2 == 1) return (power(a, b - 1) * a) % MOD;
  long long q = power(a, b / 2);
  return (q * q) % MOD;
}
void solve() {
  long long a, b;
  cin >> a >> b;
  string s1, s2;
  cin >> s1 >> s2;
  string temp = "";
  for (long long i = 0; i < -min(a, b) + max(a, b); i++) {
    temp += '0';
  }
  if (a > b)
    s2 = temp + s2;
  else
    s1 = temp + s1;
  vector<long long> suffix(max(a, b) + 5, 0);
  for (int i = s1.size() - 1; i >= 0; i--) {
    suffix[i] = suffix[i + 1];
    if (s1[i] == '1') {
      suffix[i] += power(2, s1.size() - 1 - i);
    }
    suffix[i] %= MOD;
  }
  long long ans = 0;
  for (int i = s1.size() - 1; i >= 0; i--) {
    if (s2[i] == '1') {
      ans = ans + suffix[i];
      ans = ans % MOD;
    }
  }
  cout << ans << "\n";
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  int t = 1;
  while (t--) solve();
  cerr << "Time : " << 1000 * ((double)clock()) / (double)CLOCKS_PER_SEC
       << "ms\n";
  return 0;
}
