#include<bits/stdc++.h>
#define MAXN 300005
#define MOD 1000000007
using namespace std;

int n;
char c[MAXN];
long long f[MAXN][4][4];
long long ans=0;

inline int read()
{
	int x=0,f=1;char ch=getchar();
	while(!isdigit(ch)){if(ch=='-') f=-f;ch=getchar();}
	while(isdigit(ch)){x=x*10+ch-'0';ch=getchar();}
	return x*f;
}

int main()
{
	register int i,x,y;
	scanf("%s",c+1);
	n=strlen(c+1);
	f[0][0][0]=1;
	for(i=1;i<=n;++i)
		for(x=0;x<=2;++x)
			for(y=0;y<=2;++y)
			{
				if(c[i]!='1')
				{
					if(y==2) f[i][x][y-1]=(f[i][x][y-1]+f[i-1][x][y])%MOD;
					else f[i][x][y+1]=(f[i][x][y+1]+f[i-1][x][y])%MOD;
				}
				if(c[i]!='0')
				{
					if(y==0) f[i][x+(x!=2)][y]=(f[i][x+(x!=2)][y]+f[i-1][x][y])%MOD;
					else f[i][x][y-1]=(f[i][x][y-1]+f[i-1][x][y])%MOD;
				}
			}
	for(x=0;x<=2;++x)
		for(y=x;y>=0;--y)
			ans=(ans+f[n][x][y])%MOD;
	printf("%lld",ans);
	return 0;
}
#include <bits/stdc++.h>

typedef long long ll;
const int N = 540;

int n;
int pn = 0, c[7930], p[1054];
ll a[N][N];

void sieve(int n) {
	int i, j, v;
	memset(c, -1, sizeof c);
	for (i = 2; i <= n; ++i) {
		if (!~c[i]) p[pn] = i, c[i] = pn++;
		for (j = 0; (v = i * p[j]) <= n && j <= c[i]; ++j) c[v] = j;
	}
}

int main() {
	int i, j, *q;
	scanf("%d", &n), sieve(7929);
	q = p + (n - 1);
	for (i = 0; i < n; ++i) for (j = 0; j < n; ++j) if ((i ^ j) & 1)
		a[i][j] = p[(i + j - 1) / 2] * q[(j - i + n - 1) / 2];
	for (i = 0; i < n; ++i) for (j = 0; j < n; ++j) if (!((i ^ j) & 1)) {
		ll &s = a[i][j]; s = 1;
		if (i          || j         ) s *= p[(i + j - 2) / 2];
		if (i != n - 1 || j != n - 1) s *= p[(i + j) / 2];
		if (i          || j != n - 1) s *= q[(j - i + n) / 2];
		if (i != n - 1 || j         ) s *= q[(j - i + n - 2) / 2];
		++s;
	}
	if (n == 2) a[1][1] = a[1][1] * 2 - 1;
	for (i = 0; i < n; ++i) for (j = 0; j < n; ++j)
		printf("%lld%c", a[i][j], j == n - 1 ? 10 : 32);
	return 0;
}