#include <bits/stdc++.h>
using namespace std;
const long long N = 200005;
const long long MOD = 998244353;
long long n, m, x;
long long a[N], p[N], cnt[N];
char s;
int main() {
  ios_base::sync_with_stdio(0);
  cin >> n >> m;
  for (long long i = n - 1; i >= 0; i--) {
    cin >> s;
    if (s == '1')
      a[i] = 1;
    else
      a[i] = 0;
  }
  int z;
  for (int i = 0; i < 11; i++) z = i;
  for (long long i = m - 1; i >= 0; i--) {
    cin >> s;
    if (s == '1')
      cnt[i] = cnt[i + 1] + 1;
    else
      cnt[i] = cnt[i + 1];
  }
  long long res = 0;
  p[0] = 1;
  for (long long i = 0; i <= n - 1; i++) {
    if (i != 0) p[i] = (p[i - 1] * 2) % MOD;
    if (a[i] == 0) continue;
    res = (res + (p[i] * cnt[i]) % MOD) % MOD;
  }
  cout << res;
  return 0;
}
