#include <bits/stdc++.h>
#pragma warning(disable : 4996)
using namespace std;
int gcd(int a, int b) { return b ? gcd(b, a % b) : a; }
void solution(int t) {
  int n, m;
  string s1, s2;
  cin >> n >> m;
  cin >> s1 >> s2;
  if (m > n) {
    string buf = "";
    for (int i = 0; i < m - n; i++) buf += '0';
    s1 = buf + s1;
    n = m;
  } else if (n > m) {
    string buf = "";
    for (int i = 0; i < n - m; i++) buf += '0';
    s2 = buf + s2;
    m = n;
  }
  long long cur_k = 0, k = 0;
  for (int i = 0; i < n; i++) {
    if (s2[i] == '1') cur_k++;
  }
  long long cur_step = 1;
  long long ans = 0;
  for (int i = n - 1; i >= 0; i--) {
    if (s1[i] == '1') {
      ans = (ans + cur_step * cur_k % 998244353LL) % 998244353LL;
    }
    if (s2[i] == '1') cur_k--;
    cur_step = cur_step * 2LL % 998244353LL;
  }
  cout << ans;
}
int main() {
  int t = 1;
  for (int i = 0; i < t; i++) solution(i);
  return 0;
}
