#include<bits/stdc++.h>
using namespace std;
typedef long long int LL;
LL MOD = 998244353;
const int N = 524288;
double PI = acos(-1);
struct comp {
double re, im;
comp operator*(const comp& a){
comp ret;
ret.re = re * a.re - im * a.im;
ret.im = re * a.im + im * a.re;
return ret;
}
comp operator+(const comp& a){
comp ret;
ret.re = re + a.re;
ret.im = im + a.im;
return ret;
}
comp operator-(const comp& a){
comp ret;
ret.re = re - a.re;
ret.im = im - a.im;
return ret;
}
};
int getord(int x){
int ret = 0;
while ((1 << ret) < x) {
ret++;
}
return ret;
}
comp tmp[N];
comp A[N];
comp B[N];
void fft(comp* ar, int n, int mode) {
if (n == 1) return;
comp base;
base.re = cos(2*PI/n);
base.im = sin(2*PI/n);
if (mode) base.im *= -1;
comp cur;
cur.re = 1;
cur.im = 0;
int dnc = n/2;
for (int i = 0; i < dnc; i++) {
tmp[i] = ar[i*2 + 1];
}
for (int i = 0; i < dnc; i++) {
ar[i] = ar[i*2];
}
for (int i = 0; i < dnc; i++) {
ar[i+dnc] = tmp[i];
}
fft(ar, dnc, mode);
fft(ar + dnc, dnc, mode);
for (int i = 0; i < dnc; i++) {
comp ta = ar[i];
comp tb = ar[i+dnc] * cur;
ar[i] = ta + tb;
ar[i+dnc] = ta - tb;
cur = cur * base;
}
}
char str1[200005];
char str2[200005];
int main(){
int n, m;
scanf("%d%d", &n, &m);
scanf("%s", str1);
scanf("%s", str2);
int L = (1 << getord(n+m+2));
for (int i = 0; i < L; i++) {
A[i].re = A[i].im = 0;
B[i].re = B[i].im = 0;
}
LL mul = 1;
for (int i = 0; i < n; i++) {
if (str1[n-i-1] == '1') {
A[n-i-1 + 1].re = mul;
}
mul = (mul*2)%MOD;
}
for (int i = 0; i < m; i++) {
if (str2[i] == '1') {
B[m-i-1 + 1].re = 1;
}
}
fft(A, L, 0);
fft(B, L, 0);
for (int i = 0; i < L; i++) {
A[i] = A[i] * B[i];
}
fft(A, L, 1);
LL ans = 0;
for (int i = n + 1; i < L; i++) {
LL tmp = fmod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MDAwMDEwMTAwMTExMTEwMDAwMDExMTExMDAwMDAxMTExMTAwMDAwMTExMTEwMDAwMDExMTExMDAwMDAxMTExMTAwMDAwMTAxMDAxMTExMTAwMDAwMTExMTEwMDAwMDExMTExMDAwMDAxMTExMTAwMDAwMTExMTEwMDAwMDExMTExMDAwMDAxMDEwMAo=
325 325
1111100000111110000011111000001111100000111110000011111000001010111111000001111100000111110000011111000001111100000111110000010101111110000011111000001111100000111110000011111000001111100000101011111100000111110000011111000001111100000111110000011111000001010111111000001111100000111110000011111000001111100000111110000010101
1111100000111110000011111000001111100000111110000011111000001010011111000001111100000111110000011111000001111100000111110000010100111110000011111000001111100000111110000011111000001111100000101001111100000111110000011111000001111100000111110000011111000001010011111000001111100000111110000011111000001111100000111110000010100