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