MOD = int(1e9) + 7
M = int(1e9) + 7
L = input()
N = len(L)
dp = [[0] * 2 for i in range(N+5)]
dp[0][0] = 1
for i in range(N):
    nd = int(L[i])
    for j in range(2):
        ni = i+1
        nj = j
        if j == 0:
            if nd == 0:
                dp[ni][nj] = dp[i][j]
            else:
                dp[ni][nj] = (dp[i][j] * 2) % MOD
                dp[ni][1] += dp[i][j]
        else:
            dp[ni][nj] += dp[i][j] * 3
            dp[ni][nj] %= MOD
print((dp[N][0] + dp[N][1]) % MOD) MOD = int(1e9) + 7 MOD int(1e9) + 7 int(1e9) int 1e9 7 M = int(1e9) + 7 M int(1e9) + 7 int(1e9) int 1e9 7 L = input() L input() input N = len(L) N len(L) len L [0] * 2 for i in range(N+5) for i in range(N+5) i range(N+5) range N+5 N 5 for i in range(N+5) [0] * 2 [0] 0 2 dp = [[0] * 2 for i in range(N+5)] dp [[0] * 2 for i in range(N+5)] dp[0][0] = 1 dp[0][0] [0] dp 0 0 1 for i in range(N):
    nd = int(L[i])
    for j in range(2):
        ni = i+1
        nj = j
        if j == 0:
            if nd == 0:
                dp[ni][nj] = dp[i][j]
            else:
                dp[ni][nj] = (dp[i][j] * 2) % MOD
                dp[ni][1] += dp[i][j]
        else:
            dp[ni][nj] += dp[i][j] * 3
            dp[ni][nj] %= MOD i range(N) range N nd = int(L[i]) nd int(L[i]) int L[i] L i for j in range(2):
        ni = i+1
        nj = j
        if j == 0:
            if nd == 0:
                dp[ni][nj] = dp[i][j]
            else:
                dp[ni][nj] = (dp[i][j] * 2) % MOD
                dp[ni][1] += dp[i][j]
        else:
            dp[ni][nj] += dp[i][j] * 3
            dp[ni][nj] %= MOD j range(2) range 2 ni = i+1 ni i+1 i 1 nj = j nj j if j == 0:
            if nd == 0:
                dp[ni][nj] = dp[i][j]
            else:
                dp[ni][nj] = (dp[i][j] * 2) % MOD
                dp[ni][1] += dp[i][j]
        else:
            dp[ni][nj] += dp[i][j] * 3
            dp[ni][nj] %= MOD j == 0 j 0 if nd == 0:
                dp[ni][nj] = dp[i][j]
            else:
                dp[ni][nj] = (dp[i][j] * 2) % MOD
                dp[ni][1] += dp[i][j]
         nd == 0 nd 0 dp[ni][nj] = dp[i][j] dp[ni][nj] [ni] dp ni nj dp[i][j] [i] dp i j dp[ni][nj] = (dp[i][j] * 2) % MOD dp[ni][nj] [ni] dp ni nj (dp[i][j] * 2) % MOD dp[i][j] * 2 dp[i][j] [i] dp i j 2 MOD dp[ni][1] += dp[i][j] dp[ni][1] [ni] dp ni 1 dp[i][j] [i] dp i j dp[ni][nj] += dp[i][j] * 3 dp[ni][nj] [ni] dp ni nj dp[i][j] * 3 dp[i][j] [i] dp i j 3 dp[ni][nj] %= MOD dp[ni][nj] [ni] dp ni nj MOD print((dp[N][0] + dp[N][1]) % MOD) print (dp[N][0] + dp[N][1]) % MOD dp[N][0] + dp[N][1] dp[N][0] [N] dp N 0 dp[N][1] [N] dp N 1 MOD dp = [[0] * 2 for i in range(N+5)] [[0] * 2 for i in range(N+5)] dp M = int(1e9) + 7 int(1e9) + 7 M L = input() input() L N = len(L) len(L) N MOD = int(1e9) + 7 int(1e9) + 7 MOD nd = int(L[i]) int(L[i]) nd ni = i+1 i+1 ni nj = j j nj
MOD = int(1e9) + 7
M = int(1e9) + 7
L = input()
N = len(L)
dp = [[0] * 2 for i in range(N+5)]
dp[0][0] = 1
for i in range(N):
    nd = int(L[i])
    for j in range(2):
        ni = i+1
        nj = j
        if j == 0:
            if nd == 0:
                dp[ni][nj] = dp[i][j]
            else:
                dp[ni][nj] = (dp[i][j] * 2) % MOD
                dp[ni][1] += dp[i][j]
        else:
            dp[ni][nj] += dp[i][j] * 3
            dp[ni][nj] %= MOD
print((dp[N][0] + dp[N][1]) % MOD)
