#include <bits/stdc++.h>
using namespace std;
char buf[200001];
const int N = 998244353;
int main() {
  int n, m;
  scanf("%d %d", &n, &m);
  string a, b;
  scanf("%s", buf);
  a = buf;
  scanf("%s", buf);
  b = buf;
  reverse(a.begin(), a.end());
  reverse(b.begin(), b.end());
  long pw = 1;
  long ans = 0;
  long res = 0;
  for (int i = 0; i < m; i++) {
    if (i < n && a[i] == '1') res = (res + pw) % N;
    if (b[i] == '1') ans = (ans + res) % N;
    pw = (pw + pw) % N;
  }
  cout << ans;
}
