#include <bits/stdc++.h>
using namespace std;
char s1[210000], s2[210000];
int n, m, s[210000];
int main() {
  scanf("%d%d", &n, &m);
  scanf("%s", s1 + 1);
  scanf("%s", s2 + 1);
  for (int i = 1; i <= m; i++) s[i] = s[i - 1] + (s2[i] == '1');
  long long ans = 0, t = 1;
  for (int i = n, j = m; i >= 1 && j >= 1; i--, j--) {
    if (s1[i] == '1') ans = (ans + s[j] * t % 998244353) % 998244353;
    t = t * 2 % 998244353;
  }
  cout << ans;
  return 0;
}
