#include <bits/stdc++.h>
using namespace std;
int fun(int n, int i) {
  int v = (long long)n * n % 998244353;
  if (i == 0)
    return 1;
  else if (i == 1)
    return n;
  else if (i & 1)
    return ((long long)n * (fun(v, i / 2) % 998244353)) % 998244353;
  else
    return fun(v, i / 2) % 998244353;
}
void solve() {
  int n, m;
  scanf("%d%d", &n, &m);
  string s, t;
  cin >> s >> t;
  reverse(s.begin(), s.end()), reverse(t.begin(), t.end());
  long long cnt = 0;
  for (int i = 0; i < m; i++)
    if (t[i] == '1') cnt++;
  long long ans = 0;
  for (int i = 0; i < min(m, n); i++) {
    if (s[i] == '1') ans = (ans + fun(2, i) * cnt) % 998244353;
    if (t[i] == '1') cnt--;
  }
  printf("%lld", ans % 998244353);
}
int main() {
  int t = 1;
  while (t--) solve();
  return 0;
}
