l = input()

mod = 10**9+7


dplow = [0]*len(l)
dp2 = [0]*len(l)

dplow[0] = 1
dp2[0] = 2

for i in range(1,len(l)):
    dplow[i] += dplow[i-1]*3%mod
    if l[i] == "1":
        dplow[i] += dp2[i-1]%mod
        dp2[i] += dp2[i-1]*2%mod
    else:
        dp2[i] += dp2[i-1] %mod

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

mod = 10**9+7


dplow = [0]*len(l)
dp2 = [0]*len(l)

dplow[0] = 1
dp2[0] = 2

for i in range(1,len(l)):
    dplow[i] += dplow[i-1]*3%mod
    if l[i] == "1":
        dplow[i] += dp2[i-1]%mod
        dp2[i] += dp2[i-1]*2%mod
    else:
        dp2[i] += dp2[i-1] %mod

print((dplow[-1]+dp2[-1])%mod)