#include <bits/stdc++.h>
#pragma GCC optimize("O3")
#pragma loop_opt(on)
using namespace std;
template <class T>
using vec = vector<T>;
template <class T>
using stack = stack<T, vec<T> >;
template <class T>
using MaxHeap = priority_queue<T, vec<T>, less<T> >;
template <class T>
using MinHeap = priority_queue<T, vec<T>, greater<T> >;
const long long mod = 998244353;
long long cnt[200005];
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  long long ans = 0;
  int n, m, swp = 0;
  string a, b;
  cin >> n >> m >> a >> b;
  reverse(a.begin(), a.end());
  a.resize(m);
  reverse(a.begin(), a.end());
  while ((int)a.size() < m) {
    a = '0' + a;
  }
  n = (int)a.size();
  for (int i = 0; i < m; i++) {
    if (b[i] == '1') {
      swp++;
    }
    if (a[i] == '1') cnt[i] = swp;
  }
  reverse(cnt, cnt + n);
  int idx = 1;
  for (int i = 0; i < n; i++) {
    ans += cnt[i] * idx;
    ans %= mod;
    idx <<= 1;
    idx %= mod;
  }
  cout << ans << '\n';
}
