#include <bits/stdc++.h>
using namespace std;
long long n, m, A[200016], B[200016];
long long co, ans, pw = 1;
const long long MOD = 998244353;
long long qmult(long long x, long long y) {
  if (y == 0) return 0;
  long long half = qmult(x, y / 2);
  half = (half + half) % MOD;
  if (y % 2) half = (half + x) % MOD;
  return (half % MOD);
}
long long qexp(long long x, long long y) {
  if (y == 0) return 1;
  long long half = qexp(x, y / 2);
  half = qmult(half, half);
  if (y % 2) half = qmult(half, x);
  return (half) % MOD;
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cin >> n >> m;
  for (long long i = 0; i < n; i++) {
    char ch;
    cin >> ch;
    A[i] = ch - 48;
  }
  for (long long i = 0; i < m; i++) {
    char ch;
    cin >> ch;
    B[i] = ch - 48;
  }
  reverse(A, A + n);
  reverse(B, B + m);
  for (long long i = 0; i < m; i++) {
    if (i < n && A[i] == 1) co = (co + pw) % MOD;
    pw = (pw * 2) % MOD;
    if (B[i] == 0) continue;
    ans = (ans + co) % MOD;
  }
  cout << ans << "\n";
}
