
L = input()
lenl = len(L)
MOD = 10**9 + 7
# dp[is未満][bit]
dp = [[0] * len(L) for _ in range(2)]
dp[0][0] = 2
dp[1][0] = 1

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

print((dp[0][-1] + dp[1][-1])%MOD) L = input() L input() input lenl = len(L) lenl len(L) len L MOD = 10**9 + 7 MOD 10**9 + 7 10**9 10 9 7 [0] * len(L) for _ in range(2) for _ in range(2) _ range(2) range 2 for _ in range(2) [0] * len(L) [0] 0 len(L) len L dp = [[0] * len(L) for _ in range(2)] dp [[0] * len(L) for _ in range(2)] dp[0][0] = 2 dp[0][0] [0] dp 0 0 2 dp[1][0] = 1 dp[1][0] [1] dp 1 0 1 for i in range(1,len(L)):
    b = L[i]
    if b == '1':
        dp[0][i] = dp[0][i-1]*2
        dp[1][i] = dp[0][i-1] + dp[1][i-1] * 3
    else:
        dp[0][i] = dp[0][i-1]
        dp[1][i] = dp[1][i-1] * 3
    dp[0][i] %= MOD
    dp[1][i] %= MOD i range(1,len(L)) range 1 len(L) len L b = L[i] b L[i] L i if b == '1':
        dp[0][i] = dp[0][i-1]*2
        dp[1][i] = dp[0][i-1] + dp[1][i-1] * 3
    else:
        dp[0][i] = dp[0][i-1]
        dp[1][i] = dp[1][i-1] * 3
     b == '1' b '1' dp[0][i] = dp[0][i-1]*2 dp[0][i] [0] dp 0 i dp[0][i-1]*2 dp[0][i-1] [0] dp 0 i-1 i 1 2 dp[1][i] = dp[0][i-1] + dp[1][i-1] * 3 dp[1][i] [1] dp 1 i dp[0][i-1] + dp[1][i-1] * 3 dp[0][i-1] [0] dp 0 i-1 i 1 dp[1][i-1] * 3 dp[1][i-1] [1] dp 1 i-1 i 1 3 dp[0][i] = dp[0][i-1] dp[0][i] [0] dp 0 i dp[0][i-1] [0] dp 0 i-1 i 1 dp[1][i] = dp[1][i-1] * 3 dp[1][i] [1] dp 1 i dp[1][i-1] * 3 dp[1][i-1] [1] dp 1 i-1 i 1 3 dp[0][i] %= MOD dp[0][i] [0] dp 0 i MOD dp[1][i] %= MOD dp[1][i] [1] dp 1 i 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 b = L[i] L[i] b MOD = 10**9 + 7 10**9 + 7 MOD dp = [[0] * len(L) for _ in range(2)] [[0] * len(L) for _ in range(2)] dp L = input() input() L lenl = len(L) len(L) lenl

L = input()
lenl = len(L)
MOD = 10**9 + 7
# dp[is未満][bit]
dp = [[0] * len(L) for _ in range(2)]
dp[0][0] = 2
dp[1][0] = 1

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

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