#include <bits/stdc++.h>
using namespace std;
template <typename T>
using min_queue = priority_queue<T, vector<T>, greater<T>>;
const long long MOD = 998244353;
int N, M;
long long a[200100], b[200100];
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cin >> N >> M;
  for (int i = 0; i < N; i++) {
    char c;
    cin >> c;
    a[i] = c == '1';
  }
  long long res = 0;
  for (int i = 0; i < M; i++) {
    char c;
    cin >> c;
    b[i] = c == '1';
    if (i > 0) b[i] += b[i - 1];
    int j = N - 1 - (M - 1 - i);
    if (j >= 0) res = (res * 2 + b[i] * a[j]) % MOD;
  }
  cout << res << endl;
  return 0;
}
