N = input()
k = len(N)
mod = 10**9+7
DP = [[0,0] for i in range(k+1)]
DP[0][0] = 1
DP[0][1] = 0
for i in range(1,k+1):
    if N[i-1] == "1":
        DP[i][0] = (DP[i-1][0]*2)%mod
        DP[i][1] = (DP[i-1][1]*3+DP[i-1][0])%mod
    if N[i-1] == "0":
        DP[i][0] = DP[i-1][0]
        DP[i][1] = (DP[i-1][1]*3)%mod
print((DP[k][0]+DP[k][1])%mod) N = input() N input() input k = len(N) k len(N) len N mod = 10**9+7 mod 10**9+7 10**9 10 9 7 [0,0] for i in range(k+1) for i in range(k+1) i range(k+1) range k+1 k 1 for i in range(k+1) [0,0] 0 0 DP = [[0,0] for i in range(k+1)] DP [[0,0] for i in range(k+1)] DP[0][0] = 1 DP[0][0] [0] DP 0 0 1 DP[0][1] = 0 DP[0][1] [0] DP 0 1 0 for i in range(1,k+1):
    if N[i-1] == "1":
        DP[i][0] = (DP[i-1][0]*2)%mod
        DP[i][1] = (DP[i-1][1]*3+DP[i-1][0])%mod
    if N[i-1] == "0":
        DP[i][0] = DP[i-1][0]
        DP[i][1] = (DP[i-1][1]*3)%mod i range(1,k+1) range 1 k+1 k 1 if N[i-1] == "1":
        DP[i][0] = (DP[i-1][0]*2)%mod
        DP[i][1] = (DP[i-1][1]*3+DP[i-1][0])%mod
     N[i-1] == "1" N[i-1] N i-1 i 1 "1" DP[i][0] = (DP[i-1][0]*2)%mod DP[i][0] [i] DP i 0 (DP[i-1][0]*2)%mod DP[i-1][0]*2 DP[i-1][0] [i-1] DP i-1 i 1 0 2 mod DP[i][1] = (DP[i-1][1]*3+DP[i-1][0])%mod DP[i][1] [i] DP i 1 (DP[i-1][1]*3+DP[i-1][0])%mod DP[i-1][1]*3+DP[i-1][0] DP[i-1][1]*3 DP[i-1][1] [i-1] DP i-1 i 1 1 3 DP[i-1][0] [i-1] DP i-1 i 1 0 mod if N[i-1] == "0":
        DP[i][0] = DP[i-1][0]
        DP[i][1] = (DP[i-1][1]*3)%mod N[i-1] == "0" N[i-1] N i-1 i 1 "0" DP[i][0] = DP[i-1][0] DP[i][0] [i] DP i 0 DP[i-1][0] [i-1] DP i-1 i 1 0 DP[i][1] = (DP[i-1][1]*3)%mod DP[i][1] [i] DP i 1 (DP[i-1][1]*3)%mod DP[i-1][1]*3 DP[i-1][1] [i-1] DP i-1 i 1 1 3 mod print((DP[k][0]+DP[k][1])%mod) print (DP[k][0]+DP[k][1])%mod DP[k][0]+DP[k][1] DP[k][0] [k] DP k 0 DP[k][1] [k] DP k 1 mod DP = [[0,0] for i in range(k+1)] [[0,0] for i in range(k+1)] DP mod = 10**9+7 10**9+7 mod k = len(N) len(N) k N = input() input() N
N = input()
k = len(N)
mod = 10**9+7
DP = [[0,0] for i in range(k+1)]
DP[0][0] = 1
DP[0][1] = 0
for i in range(1,k+1):
    if N[i-1] == "1":
        DP[i][0] = (DP[i-1][0]*2)%mod
        DP[i][1] = (DP[i-1][1]*3+DP[i-1][0])%mod
    if N[i-1] == "0":
        DP[i][0] = DP[i-1][0]
        DP[i][1] = (DP[i-1][1]*3)%mod
print((DP[k][0]+DP[k][1])%mod)