#include <bits/stdc++.h>
using namespace std;
char a[200010], b[200010];
int s[200010];
int main() {
  int n, m, mul = 1, ans = 0;
  scanf("%d%d", &n, &m);
  scanf("%s%s", a + 1, b + 1);
  for (int i = 1; i <= m; ++i) s[i] = s[i - 1] + b[i] - '0';
  for (int i = n; i; --i) {
    if (a[i] == '1' && n - i < m) {
      int res = (long long)mul * s[m - (n - i)] % 998244353;
      ans += res;
      if (ans >= 998244353) ans -= 998244353;
    }
    mul += mul;
    if (mul >= 998244353) mul -= 998244353;
  }
  cout << ans;
}
