L = input()
N = len(L)

mod = 10**9 + 7

dp = [[0]*(N+1) for _ in range(2)]
dp[1][0] = 1

for i in range(1, N+1):
    c = L[i-1]
    if c == '1':
        dp[1][i] = 2*dp[1][i-1] % mod
        dp[0][i] = (3*dp[0][i-1] + dp[1][i-1]) % mod
    else:
        dp[1][i] = dp[1][i-1]
        dp[0][i] = 3*dp[0][i-1] % mod

print((dp[0][-1] + dp[1][-1]) % mod) L = input() L input() input N = len(L) N len(L) len L mod = 10**9 + 7 mod 10**9 + 7 10**9 10 9 7 [0]*(N+1) for _ in range(2) for _ in range(2) _ range(2) range 2 for _ in range(2) [0]*(N+1) [0] 0 N+1 N 1 dp = [[0]*(N+1) for _ in range(2)] dp [[0]*(N+1) for _ in range(2)] dp[1][0] = 1 dp[1][0] [1] dp 1 0 1 for i in range(1, N+1):
    c = L[i-1]
    if c == '1':
        dp[1][i] = 2*dp[1][i-1] % mod
        dp[0][i] = (3*dp[0][i-1] + dp[1][i-1]) % mod
    else:
        dp[1][i] = dp[1][i-1]
        dp[0][i] = 3*dp[0][i-1] % mod i range(1, N+1) range 1 N+1 N 1 c = L[i-1] c L[i-1] L i-1 i 1 if c == '1':
        dp[1][i] = 2*dp[1][i-1] % mod
        dp[0][i] = (3*dp[0][i-1] + dp[1][i-1]) % mod
    else:
        dp[1][i] = dp[1][i-1]
        dp[0][i] = 3*dp[0][i-1] % mod c == '1' c '1' dp[1][i] = 2*dp[1][i-1] % mod dp[1][i] [1] dp 1 i 2*dp[1][i-1] % mod 2*dp[1][i-1] 2 dp[1][i-1] [1] dp 1 i-1 i 1 mod dp[0][i] = (3*dp[0][i-1] + dp[1][i-1]) % mod dp[0][i] [0] dp 0 i (3*dp[0][i-1] + dp[1][i-1]) % mod 3*dp[0][i-1] + dp[1][i-1] 3*dp[0][i-1] 3 dp[0][i-1] [0] dp 0 i-1 i 1 dp[1][i-1] [1] dp 1 i-1 i 1 mod dp[1][i] = dp[1][i-1] dp[1][i] [1] dp 1 i dp[1][i-1] [1] dp 1 i-1 i 1 dp[0][i] = 3*dp[0][i-1] % mod dp[0][i] [0] dp 0 i 3*dp[0][i-1] % mod 3*dp[0][i-1] 3 dp[0][i-1] [0] dp 0 i-1 i 1 mod print((dp[0][-1] + dp[1][-1]) % mod) print (dp[0][-1] + dp[1][-1]) % mod dp[0][-1] + dp[1][-1] dp[0][-1] [0] dp 0 -1 dp[1][-1] [1] dp 1 -1 mod N = len(L) len(L) N c = L[i-1] L[i-1] c dp = [[0]*(N+1) for _ in range(2)] [[0]*(N+1) for _ in range(2)] dp L = input() input() L mod = 10**9 + 7 10**9 + 7 mod
L = input()
N = len(L)

mod = 10**9 + 7

dp = [[0]*(N+1) for _ in range(2)]
dp[1][0] = 1

for i in range(1, N+1):
    c = L[i-1]
    if c == '1':
        dp[1][i] = 2*dp[1][i-1] % mod
        dp[0][i] = (3*dp[0][i-1] + dp[1][i-1]) % mod
    else:
        dp[1][i] = dp[1][i-1]
        dp[0][i] = 3*dp[0][i-1] % mod

print((dp[0][-1] + dp[1][-1]) % mod)
