L=input()
L=L+"0"
L=L[::-1]
pow3=[0 for i in range(110000)]
pow3[0]=1
mod=10**9+7
for i in range(1,100010):
    pow3[i]=pow3[i-1]*3%mod
#pow3[i]=3**iをmodで割ったあまり
a=1
for i in range(len(L)):
    if L[i]=="1":
        a=(a*2+pow3[i-1])%mod
print(a%mod) L=input() L input() input L=L+"0" L L+"0" L "0" L=L[::-1] L L[::-1] L ::-1 -1 0 for i in range(110000) for i in range(110000) i range(110000) range 110000 for i in range(110000) 0 pow3=[0 for i in range(110000)] pow3 [0 for i in range(110000)] pow3[0]=1 pow3[0] pow3 0 1 mod=10**9+7 mod 10**9+7 10**9 10 9 7 for i in range(1,100010):
    pow3[i]=pow3[i-1]*3%mod
#pow3[i]=3**iをmodで割ったあまり i range(1,100010) range 1 100010 pow3[i]=pow3[i-1]*3%mod pow3[i] pow3 i pow3[i-1]*3%mod pow3[i-1]*3 pow3[i-1] pow3 i-1 i 1 3 mod a=1 a 1 for i in range(len(L)):
    if L[i]=="1":
        a=(a*2+pow3[i-1])%mod i range(len(L)) range len(L) len L if L[i]=="1":
        a=(a*2+pow3[i-1])%mod L[i]=="1" L[i] L i "1" a=(a*2+pow3[i-1])%mod a (a*2+pow3[i-1])%mod a*2+pow3[i-1] a*2 a 2 pow3[i-1] pow3 i-1 i 1 mod print(a%mod) print a%mod a mod L=L+"0" L+"0" L L=L[::-1] L[::-1] L mod=10**9+7 10**9+7 mod a=(a*2+pow3[i-1])%mod (a*2+pow3[i-1])%mod a a=1 1 a L=input() input() L pow3=[0 for i in range(110000)] [0 for i in range(110000)] pow3
L=input()
L=L+"0"
L=L[::-1]
pow3=[0 for i in range(110000)]
pow3[0]=1
mod=10**9+7
for i in range(1,100010):
    pow3[i]=pow3[i-1]*3%mod
#pow3[i]=3**iをmodで割ったあまり
a=1
for i in range(len(L)):
    if L[i]=="1":
        a=(a*2+pow3[i-1])%mod
print(a%mod)