L = input()
Digit = len(L)
dp = [[0]*2 for _ in range(Digit+1)]
dp[0][0] = 1
mod = 10**9+7
# 配りdp
for i in range(Digit):
    next_digit = L[i]
    
    if next_digit == '0':
        # not smallからnot smallへの遷移
        dp[i+1][0] += dp[i][0]
        # not smallからsmallへの遷移はない

        # smallからsmallへの遷移
        dp[i+1][1] += (3*dp[i][1])%mod
        
    else:
        # not smallからnot smallへの遷移
        dp[i+1][0] += (2*dp[i][0])%mod
        # not smallからsmallへの遷移
        #print(dp[i][0])
        dp[i+1][1] += dp[i][0]%mod
        # smallからsmallへの遷移
        dp[i+1][1] += (3*dp[i][1])%mod
    #print(dp[i],dp[i+1])
    #print('---')

#print(dp)
print((dp[-1][1]+dp[-1][0])%mod) L = input() L input() input Digit = len(L) Digit len(L) len L [0]*2 for _ in range(Digit+1) for _ in range(Digit+1) _ range(Digit+1) range Digit+1 Digit 1 for _ in range(Digit+1) [0]*2 [0] 0 2 dp = [[0]*2 for _ in range(Digit+1)] dp [[0]*2 for _ in range(Digit+1)] dp[0][0] = 1 dp[0][0] [0] dp 0 0 1 mod = 10**9+7 mod 10**9+7 10**9 10 9 7 for i in range(Digit):
    next_digit = L[i]
    
    if next_digit == '0':
        # not smallからnot smallへの遷移
        dp[i+1][0] += dp[i][0]
        # not smallからsmallへの遷移はない

        # smallからsmallへの遷移
        dp[i+1][1] += (3*dp[i][1])%mod
        
    else:
        # not smallからnot smallへの遷移
        dp[i+1][0] += (2*dp[i][0])%mod
        # not smallからsmallへの遷移
        #print(dp[i][0])
        dp[i+1][1] += dp[i][0]%mod
        # smallからsmallへの遷移
        dp[i+1][1] += (3*dp[i][1])%mod
    #print(dp[i],dp[i+1])
    #print('---')

#print(dp) i range(Digit) range Digit next_digit = L[i] next_digit L[i] L i if next_digit == '0':
        # not smallからnot smallへの遷移
        dp[i+1][0] += dp[i][0]
        # not smallからsmallへの遷移はない

        # smallからsmallへの遷移
        dp[i+1][1] += (3*dp[i][1])%mod
        
    else:
        # not smallからnot smallへの遷移
        dp[i+1][0] += (2*dp[i][0])%mod
        # not smallからsmallへの遷移
        #print(dp[i][0])
        dp[i+1][1] += dp[i][0]%mod
        # smallからsmallへの遷移
        dp[i+1][1] += (3*dp[i][1])%mod
    #print(dp[i],dp[i+1])
    #print('---')

#print(dp) next_digit == '0' next_digit '0' 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] += (3*dp[i][1])%mod dp[i+1][1] [i+1] dp i+1 i 1 1 (3*dp[i][1])%mod 3*dp[i][1] 3 dp[i][1] [i] dp i 1 mod dp[i+1][0] += (2*dp[i][0])%mod dp[i+1][0] [i+1] dp i+1 i 1 0 (2*dp[i][0])%mod 2*dp[i][0] 2 dp[i][0] [i] dp i 0 mod dp[i+1][1] += dp[i][0]%mod dp[i+1][1] [i+1] dp i+1 i 1 1 dp[i][0]%mod dp[i][0] [i] dp i 0 mod dp[i+1][1] += (3*dp[i][1])%mod dp[i+1][1] [i+1] dp i+1 i 1 1 (3*dp[i][1])%mod 3*dp[i][1] 3 dp[i][1] [i] dp i 1 mod print((dp[-1][1]+dp[-1][0])%mod) print (dp[-1][1]+dp[-1][0])%mod dp[-1][1]+dp[-1][0] dp[-1][1] [-1] dp -1 1 dp[-1][0] [-1] dp -1 0 mod next_digit = L[i] L[i] next_digit mod = 10**9+7 10**9+7 mod L = input() input() L Digit = len(L) len(L) Digit dp = [[0]*2 for _ in range(Digit+1)] [[0]*2 for _ in range(Digit+1)] dp
L = input()
Digit = len(L)
dp = [[0]*2 for _ in range(Digit+1)]
dp[0][0] = 1
mod = 10**9+7
# 配りdp
for i in range(Digit):
    next_digit = L[i]
    
    if next_digit == '0':
        # not smallからnot smallへの遷移
        dp[i+1][0] += dp[i][0]
        # not smallからsmallへの遷移はない

        # smallからsmallへの遷移
        dp[i+1][1] += (3*dp[i][1])%mod
        
    else:
        # not smallからnot smallへの遷移
        dp[i+1][0] += (2*dp[i][0])%mod
        # not smallからsmallへの遷移
        #print(dp[i][0])
        dp[i+1][1] += dp[i][0]%mod
        # smallからsmallへの遷移
        dp[i+1][1] += (3*dp[i][1])%mod
    #print(dp[i],dp[i+1])
    #print('---')

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