
L = input()
N = len(L)
MOD = 10**9 + 7

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


for i in range(N):
    if L[i] == "1":
        dp[i+1][1] += dp[i][1] * 3 # (a,b) = (0,0),(1,0),(0,1)
        dp[i+1][1] += dp[i][0] # (0,0)
        dp[i+1][0] += dp[i][0] * 2 # (1,0) (0,1)
    else:
        dp[i+1][1] += dp[i][1] * 3 # (a,b) = (0,0),(1,0),(0,1)
        # dp[i+1][1] += dp[i][0] # a + b = a xor b を満たせないので、この遷移はない
        dp[i+1][0] += dp[i][0]  # (0,0) 

    dp[i+1][1] %= MOD
    dp[i+1][0] %= MOD
    

print(sum(dp[-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 for _ in range(2)] for _ in range(N+1) for _ in range(N+1) _ range(N+1) range N+1 N 1 for _ in range(N+1) [0 for _ in range(2)] dp = [[0 for _ in range(2)] for _ in range(N+1)] dp [[0 for _ in range(2)] for _ in range(N+1)] dp[0][0] = 1 dp[0][0] [0] dp 0 0 1 for i in range(N):
    if L[i] == "1":
        dp[i+1][1] += dp[i][1] * 3 # (a,b) = (0,0),(1,0),(0,1)
        dp[i+1][1] += dp[i][0] # (0,0)
        dp[i+1][0] += dp[i][0] * 2 # (1,0) (0,1)
    else:
        dp[i+1][1] += dp[i][1] * 3 # (a,b) = (0,0),(1,0),(0,1)
        # dp[i+1][1] += dp[i][0] # a + b = a xor b を満たせないので、この遷移はない
        dp[i+1][0] += dp[i][0]  # (0,0) 

    dp[i+1][1] %= MOD
    dp[i+1][0] %= MOD
     i range(N) range N if L[i] == "1":
        dp[i+1][1] += dp[i][1] * 3 # (a,b) = (0,0),(1,0),(0,1)
        dp[i+1][1] += dp[i][0] # (0,0)
        dp[i+1][0] += dp[i][0] * 2 # (1,0) (0,1)
    else:
        dp[i+1][1] += dp[i][1] * 3 # (a,b) = (0,0),(1,0),(0,1)
        # dp[i+1][1] += dp[i][0] # a + b = a xor b を満たせないので、この遷移はない
        dp[i+1][0] += dp[i][0]  # (0,0) 

     L[i] == "1" L[i] L i "1" dp[i+1][1] += dp[i][1] * 3 dp[i+1][1] [i+1] dp i+1 i 1 1 dp[i][1] * 3 dp[i][1] [i] dp i 1 3 dp[i+1][1] += dp[i][0] dp[i+1][1] [i+1] dp i+1 i 1 1 dp[i][0] [i] dp i 0 dp[i+1][0] += dp[i][0] * 2 dp[i+1][0] [i+1] dp i+1 i 1 0 dp[i][0] * 2 dp[i][0] [i] dp i 0 2 dp[i+1][1] += dp[i][1] * 3 dp[i+1][1] [i+1] dp i+1 i 1 1 dp[i][1] * 3 dp[i][1] [i] dp i 1 3 dp[i+1][0] += dp[i][0] dp[i+1][0] [i+1] dp i+1 i 1 0 dp[i][0] [i] dp i 0 dp[i+1][1] %= MOD dp[i+1][1] [i+1] dp i+1 i 1 1 MOD dp[i+1][0] %= MOD dp[i+1][0] [i+1] dp i+1 i 1 0 MOD print(sum(dp[-1]) % MOD) print sum(dp[-1]) % MOD sum(dp[-1]) sum dp[-1] dp -1 MOD L = input() input() L N = len(L) len(L) N dp = [[0 for _ in range(2)] for _ in range(N+1)] [[0 for _ in range(2)] for _ in range(N+1)] dp MOD = 10**9 + 7 10**9 + 7 MOD

L = input()
N = len(L)
MOD = 10**9 + 7

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


for i in range(N):
    if L[i] == "1":
        dp[i+1][1] += dp[i][1] * 3 # (a,b) = (0,0),(1,0),(0,1)
        dp[i+1][1] += dp[i][0] # (0,0)
        dp[i+1][0] += dp[i][0] * 2 # (1,0) (0,1)
    else:
        dp[i+1][1] += dp[i][1] * 3 # (a,b) = (0,0),(1,0),(0,1)
        # dp[i+1][1] += dp[i][0] # a + b = a xor b を満たせないので、この遷移はない
        dp[i+1][0] += dp[i][0]  # (0,0) 

    dp[i+1][1] %= MOD
    dp[i+1][0] %= MOD
    

print(sum(dp[-1]) % MOD)