#include <bits/stdc++.h>
using namespace std;
template <typename Arg1>
void __f(const char* name, Arg1&& arg1) {
  cerr << name << " : " << arg1 << endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args) {
  const char* comma = strchr(names + 1, ',');
  cerr.write(names, comma - names) << " : " << arg1 << " | ";
  __f(comma + 1, args...);
}
long long my_pow(int idx) {
  if (idx == 0) return 1;
  if (idx == 1) return 2;
  long long temp = my_pow(idx >> 1) % 998244353;
  temp = (temp * temp) % 998244353;
  if (idx & 1) temp = (temp * 2) % 998244353;
  return temp % 998244353;
}
int main() {
  int n, m;
  string a, b;
  scanf("%d", &n);
  scanf("%d", &m);
  cin >> a;
  cin >> b;
  long long ans = 0;
  vector<int> sorted_indices;
  vector<int> cum_sum;
  map<int, long long> index_vals;
  int siz_a = int((a).size());
  int siz_b = int((b).size());
  for (int i = siz_a - 1; i >= 0; i--) {
    if (a[i] - '0' == 0) continue;
    int act_idx = siz_a - 1 - i;
    sorted_indices.push_back(act_idx);
    auto val = my_pow(act_idx);
    index_vals[act_idx] = val;
  }
  long long temp_sum = 0;
  for (auto it : sorted_indices) {
    temp_sum = (temp_sum + index_vals[it]) % 998244353;
    index_vals[it] = temp_sum;
  }
  for (int i = 0; i < siz_b; i++) {
    if (b[i] - '0' == 1) {
      auto act_idx = siz_b - 1 - i;
      auto temp_idx =
          lower_bound(sorted_indices.begin(), sorted_indices.end(), act_idx) -
          sorted_indices.begin();
      if (act_idx != sorted_indices[temp_idx]) temp_idx--;
      auto my_num = sorted_indices[temp_idx];
      ans = (ans + index_vals[my_num]) % 998244353;
    }
  }
  cout << ans << endl;
  return 0;
}
