mod = 1000000007

l = input()
n = len(l)
dp = [[0, 0] for _ in range(n+1)]

dp[0][1] = 1
for i in range(n):
    if l[i] == '1':
        dp[i + 1][0] = (dp[i][0] * 3 + dp[i][1]) % mod
        dp[i + 1][1] = (dp[i][1] * 2) % mod
    else:
        dp[i + 1][0] = (dp[i][0] * 3) % mod
        dp[i + 1][1] = dp[i][1]
print((dp[n][0] + dp[n][1]) % mod) mod = 1000000007 mod 1000000007 l = input() l input() input n = len(l) n len(l) len l [0, 0] for _ in range(n+1) for _ in range(n+1) _ range(n+1) range n+1 n 1 for _ in range(n+1) [0, 0] 0 0 dp = [[0, 0] for _ in range(n+1)] dp [[0, 0] for _ in range(n+1)] dp[0][1] = 1 dp[0][1] [0] dp 0 1 1 for i in range(n):
    if l[i] == '1':
        dp[i + 1][0] = (dp[i][0] * 3 + dp[i][1]) % mod
        dp[i + 1][1] = (dp[i][1] * 2) % mod
    else:
        dp[i + 1][0] = (dp[i][0] * 3) % mod
        dp[i + 1][1] = dp[i][1] i range(n) range n if l[i] == '1':
        dp[i + 1][0] = (dp[i][0] * 3 + dp[i][1]) % mod
        dp[i + 1][1] = (dp[i][1] * 2) % mod
    else:
        dp[i + 1][0] = (dp[i][0] * 3) % mod
        dp[i + 1][1] = dp[i][1] l[i] == '1' l[i] l i '1' dp[i + 1][0] = (dp[i][0] * 3 + dp[i][1]) % mod dp[i + 1][0] [i + 1] dp i + 1 i 1 0 (dp[i][0] * 3 + dp[i][1]) % mod dp[i][0] * 3 + dp[i][1] dp[i][0] * 3 dp[i][0] [i] dp i 0 3 dp[i][1] [i] dp i 1 mod dp[i + 1][1] = (dp[i][1] * 2) % mod dp[i + 1][1] [i + 1] dp i + 1 i 1 1 (dp[i][1] * 2) % mod dp[i][1] * 2 dp[i][1] [i] dp i 1 2 mod dp[i + 1][0] = (dp[i][0] * 3) % mod dp[i + 1][0] [i + 1] dp i + 1 i 1 0 (dp[i][0] * 3) % mod dp[i][0] * 3 dp[i][0] [i] dp i 0 3 mod dp[i + 1][1] = dp[i][1] dp[i + 1][1] [i + 1] dp i + 1 i 1 1 dp[i][1] [i] dp i 1 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 l = input() input() l n = len(l) len(l) n dp = [[0, 0] for _ in range(n+1)] [[0, 0] for _ in range(n+1)] dp mod = 1000000007 1000000007 mod
mod = 1000000007

l = input()
n = len(l)
dp = [[0, 0] for _ in range(n+1)]

dp[0][1] = 1
for i in range(n):
    if l[i] == '1':
        dp[i + 1][0] = (dp[i][0] * 3 + dp[i][1]) % mod
        dp[i + 1][1] = (dp[i][1] * 2) % mod
    else:
        dp[i + 1][0] = (dp[i][0] * 3) % mod
        dp[i + 1][1] = dp[i][1]
print((dp[n][0] + dp[n][1]) % mod)
