#include <bits/stdc++.h>
using namespace std;
const double EPS = 1e-6;
const double PI = acos(-1);
const long long INF = 1e18;
void FAST() {
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  cout.tie(nullptr);
}
signed main() {
  FAST();
  int n, m;
  cin >> n >> m;
  string a, b;
  cin >> a >> b;
  while (n < m) a = "0" + a, n++;
  while (n > m) b = "0" + b, m++;
  const long long MOD = 998244353;
  vector<long long> ppow(n);
  ppow[0] = 1;
  for (int i = 1; i < n; i++) {
    ppow[i] = (ppow[i - 1] * 2) % MOD;
  }
  long long cnt = 0, ans = 0;
  for (int i = 0; i < n; i++) {
    if (b[i] == '1') cnt++;
    if (a[i] == '1') {
      ans += cnt * ppow[n - 1 - i];
      ans %= MOD;
    }
  }
  cout << ans;
}
