#include <bits/stdc++.h>
using namespace std;
const unsigned long long maxN = 2e5 + 5;
const unsigned long long maxM = 2e5 + 5;
const unsigned long long MOD = 998244353;
long long cnt, n, m;
unsigned long long res;
unsigned long long p2[maxN];
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  string a, b;
  cin >> n >> m >> a >> b;
  a = string(a.rbegin(), a.rend());
  b = string(b.rbegin(), b.rend());
  p2[0] = 1;
  for (long long i = (1), _b = (min(n, m)); i <= (_b); i++)
    p2[i] = (p2[i - 1] << 1) % MOD;
  for (long long i = (max(n, m) - 1), _b = (0); i >= (_b); i--) {
    if (i < m && b[i] == '1') cnt++;
    if (i < n && a[i] == '1')
      res = (((res) + ((((cnt) * (p2[i])) % MOD))) % MOD);
  }
  cout << res << '\n';
  return 0;
}
