#include <bits/stdc++.h>
using namespace std;
const long long llinf = 0x3f3f3f3f3f3f3f3f;
const int inf = 0x3f3f3f3f;
const int maxn = int(2e5 + 10);
const int MOD = 998244353;
string a, b;
long long ppow[maxn], sum[maxn];
int main() {
  int T(1), times(0);
  std::ios::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  while (++times, T--) {
    int n, m;
    cin >> n >> m;
    cin >> a >> b;
    ppow[0] = 1;
    long long ans(0);
    for (int i = 1; i <= 2e5; i++) {
      ppow[i] = (ppow[i - 1] << 1);
      if (ppow[i] >= MOD) ppow[i] -= MOD;
    }
    if (n >= m)
      for (int i = n - m; i < n; ++i) {
        sum[i] = (b[i - (n - m)] == '1') + ((i == (n - m)) ? 0 : sum[i - 1]);
      }
    else {
      for (int i = 0; i <= m - n; ++i) sum[0] += b[i] == '1';
      for (int i = 1; i < n; ++i) sum[i] = sum[i - 1] + (b[i + (m - n)] == '1');
    }
    for (int i = 0; i < n; ++i) {
      if (a[i] == '1') {
        ans += ppow[(n - 1) - i] * sum[i];
        ans %= MOD;
      }
    }
    cout << ans << endl;
  }
  return 0;
}
