#include <bits/stdc++.h>
#define endl '\n'

using namespace std;
template<class T, class T2> inline void chkmax(T &x, const T2 &y) { if(x < y) x = y; }
template<class T, class T2> inline void chkmin(T &x, const T2 &y) { if(x > y) x = y; }
const int MAXN = (int)3e5 + 17;
const int mod = (int)1e9 + 7;
const int OFFSET = 5;

int n, suff[MAXN];
string s;

void read()
{
	cin >> s;
	n = s.size();
}

int dp[MAXN][10][4];

int rec(int pos, int len, int bd)
{
	if(bd > 2)
	{
		if(bd % 2 == 0) len += (bd - 2), bd = 2;
		if(bd % 2 == 1) len += (bd - 1), bd = 1;
	}

	if(bd < 0) bd = 0;
	if(len > 4) len = 4;

	if(pos == n)
	{
		if(len > 0) return 1;
		return 0;
	}

	int &memo = dp[pos][len + OFFSET][bd];
	if(memo != -1) return memo;
	memo = 0;

	if(s[pos] == '1' || s[pos] == '?') memo = (memo + rec(pos + 1, len + 1, bd - 1)) % mod;
	if(s[pos] == '0' || s[pos] == '?') memo = (memo + rec(pos + 1, len - 1, bd + 1)) % mod; 
	return memo;
}

void solve()
{
	suff[n] = 1;
	for(int i = n - 1; i >= 0; i--)
	{
		suff[i] = suff[i + 1];
		if(s[i] == '?') suff[i] = (2ll * suff[i + 1]) % mod;
	}

	memset(dp, -1, sizeof(dp));
	cout << rec(0, 0, 0) << endl;
}

int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);

	read();
	solve();
	return 0;
}


#include<bits/stdc++.h>
using namespace std;
#define MAXN	1000005
#define P	998244353
template <typename T> void read(T &x) {
	x = 0; int f = 1;
	char c = getchar();
	for (; !isdigit(c); c = getchar()) if (c == '-') f = -f;
	for (; isdigit(c); c = getchar()) x = x * 10 + c - '0';
	x *= f;
}
long long fac[MAXN], inv[MAXN];
void update(long long &x, long long y) {
	x = (x + y) % P;
}
long long power(long long x, long long y) {
	if (y == 0) return 1;
	long long tmp = power(x, y / 2);
	if (y % 2 == 0) return tmp * tmp % P;
	else return tmp * tmp % P * x % P;
}
long long getc(long long x, long long y) {
	return fac[x] * inv[y] % P * inv[x - y] % P;
}
int main() {
	int n, m;
	read(n), read(m);
	if (n < m) swap(n, m);
	fac[0] = 1;
	for (int i = 1; i <= n + m; i++)
		fac[i] = fac[i - 1] * i % P;
	inv[n + m] = power(fac[n + m], P - 2);
	for (int i = n + m - 1; i >= 0; i--)
		inv[i] = inv[i + 1] * (i + 1) % P;
	long long ans = 0;
	for (int i = 1; i <= m; i++)
		update(ans, getc(2 * i, i) * getc(n + m - 2 * i, m - i));
	ans = ans * power(getc(n + m, m) * 2 % P, P - 2) % P;
	update(ans, n);
	cout << ans << endl;
	return 0;
}