#include <bits/stdc++.h>
using namespace std;
const long long MAXN = 2e5;
const long long MOD = 998244353;
long long n, m;
string A, B;
signed main() {
  cin >> n >> m;
  cin >> A >> B;
  long long sum = 0;
  long long pw = 1;
  long long st = 0;
  for (long long i = 0; i < m; ++i) {
    if (i < n && A[n - i - 1] == '1') st = (st + pw) % MOD;
    if (B[m - i - 1] == '1') sum = (sum + st) % MOD;
    pw = (2 * pw) % MOD;
  }
  cout << sum;
  return 0;
}
