l=input()
mod=10**9+7

# dp[digit][smaller]
# dp[i][j]
dp = [[0 for _ in range(2)] for _ in range(len(l)+1)]
dp[0][0]=1 # smaller:1==False
for i in range(len(l)):
    dp[i+1][1] += (3*dp[i][1])
    if l[i] == "1":
        dp[i+1][1] += dp[i][0]
        dp[i+1][0] += (2*dp[i][0])
    else:
        dp[i+1][0] += dp[i][0]
    dp[i+1][0] %= mod
    dp[i+1][1] %= mod

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

# dp[digit][smaller]
# dp[i][j]
dp = [[0 for _ in range(2)] for _ in range(len(l)+1)]
dp[0][0]=1 # smaller:1==False
for i in range(len(l)):
    dp[i+1][1] += (3*dp[i][1])
    if l[i] == "1":
        dp[i+1][1] += dp[i][0]
        dp[i+1][0] += (2*dp[i][0])
    else:
        dp[i+1][0] += dp[i][0]
    dp[i+1][0] %= mod
    dp[i+1][1] %= mod

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