#include <bits/stdc++.h>
using namespace std;
const int INF = 987654321;
const int MOD = 998244353;
int main() {
  int N, M;
  scanf("%d %d", &N, &M);
  long long c[200005] = {1, 2};
  for (int i = 2; i <= 200002; i++) {
    c[i] = (c[i - 1] * 2) % MOD;
  }
  vector<long long> a, b;
  for (int i = 0; i < N; i++) {
    int X;
    scanf("%1d", &X);
    a.push_back(X);
  }
  for (int i = 0; i < M; i++) {
    int X;
    scanf("%1d", &X);
    b.push_back(X);
  }
  for (int i = 1; i < M; i++) b[i] += b[i - 1];
  long long ans = 0;
  for (int i = 0; i < N; i++) {
    if (M - 1 - i < 0) break;
    ans = (ans + (a[N - 1 - i] * c[i] * b[M - 1 - i]) % MOD) % MOD;
  }
  printf("%lld\n", ans);
}
