#include <bits/stdc++.h>
using namespace std;
int n, m;
string a, b;
long long power[200009], pre[200009];
const long long MOD = 998244353;
long long ans;
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(NULL);
  cin >> n >> m;
  cin >> a >> b;
  power[0] = 1;
  for (int i = 1; i < 200000; i++) {
    power[i] = power[i - 1] * 2 * 1LL;
    power[i] = (power[i] + MOD) % MOD;
  }
  reverse(a.begin(), a.end());
  reverse(b.begin(), b.end());
  while (a.size() > b.size()) b += '0';
  if (a[0] == '1') {
    pre[0] = 1;
  }
  for (int i = 1; i < n; i++) {
    pre[i] = pre[i - 1];
    if (a[i] == '1') {
      pre[i] += power[i];
    }
    pre[i] = (pre[i] + MOD) % MOD;
  }
  for (int i = n; i < 200000; i++) {
    pre[i] = pre[i - 1];
  }
  for (int i = 0; i < b.size(); i++) {
    if (b[i] == '1') {
      ans += pre[i];
    }
    ans = (ans + MOD) % MOD;
  }
  cout << ans << "\n";
}
