#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);
  int n, m;
  cin >> n >> m;
  string str1, str2;
  cin >> str1 >> str2;
  reverse(str1.begin(), str1.end());
  reverse(str2.begin(), str2.end());
  vector<long long> dp(m + 1, 0);
  for (int i = m - 1; i >= 0; i--) dp[i] = dp[i + 1] + ((str2[i] - '0') & 1);
  int ind = n;
  if (n > m) ind = m;
  vector<long long> ans(ind + 1, 1);
  for (int i = 1; i <= ind; i++) ans[i] = (ans[i - 1] * 2) % 998244353;
  long long total = 0;
  for (int i = 0; i < ind; i++) {
    if (str1[i] == '1')
      total = (total + (dp[i] * ans[i]) % 998244353) % 998244353;
  }
  cout << total % 998244353;
}
