#include <bits/stdc++.h>
using namespace std;
const int64_t N = 2 * 1000 * 100 + 2000;
const int64_t M = 998244353;
int64_t pos[N];
int64_t p[N];
void Z() {
  p[0] = 1;
  for (int64_t i = 1; i < 200010; i++) {
    p[i] = (p[i - 1] * 2) % M;
  }
}
int32_t main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  Z();
  int64_t n, m;
  cin >> n >> m;
  string s1, s2;
  cin >> s1 >> s2;
  reverse(s1.begin(), s1.end());
  reverse(s2.begin(), s2.end());
  if (s1[0] == '1') pos[0] = 1;
  for (int64_t i = 1; i < n; i++) {
    if (s1[i] == '1') {
      pos[i] = (pos[i - 1] + p[i]) % M;
    } else {
      pos[i] = pos[i - 1];
    }
  }
  for (int64_t i = n; i < m; i++) pos[i] = pos[i - 1];
  int64_t ans = 0;
  for (int64_t i = 0; i < m; i++) {
    if (s2[i] == '1') {
      ans += pos[i];
      ans %= M;
    }
  }
  cout << ans;
}
