S=input()
L=[0]*len(S)
for i in range(len(S)):
    L[i]=int(S[i])

mod=10**9+7    
    
N=len(S)
power=[1]*(N+3)
for i in range(1,N+3):
    power[i]=(power[i-1]*3)%mod

    

ans=1
for i in range(N):
    if L[N-1-i]==1:
        ans=(2*ans+power[i])%mod
print(ans%mod) S=input() S input() input L=[0]*len(S) L [0]*len(S) [0] 0 len(S) len S for i in range(len(S)):
    L[i]=int(S[i]) i range(len(S)) range len(S) len S L[i]=int(S[i]) L[i] L i int(S[i]) int S[i] S i mod=10**9+7 mod 10**9+7 10**9 10 9 7 N=len(S) N len(S) len S power=[1]*(N+3) power [1]*(N+3) [1] 1 N+3 N 3 for i in range(1,N+3):
    power[i]=(power[i-1]*3)%mod

     i range(1,N+3) range 1 N+3 N 3 power[i]=(power[i-1]*3)%mod power[i] power i (power[i-1]*3)%mod power[i-1]*3 power[i-1] power i-1 i 1 3 mod ans=1 ans 1 for i in range(N):
    if L[N-1-i]==1:
        ans=(2*ans+power[i])%mod i range(N) range N if L[N-1-i]==1:
        ans=(2*ans+power[i])%mod L[N-1-i]==1 L[N-1-i] L N-1-i N-1 N 1 i 1 ans=(2*ans+power[i])%mod ans (2*ans+power[i])%mod 2*ans+power[i] 2*ans 2 ans power[i] power i mod print(ans%mod) print ans%mod ans mod ans=1 1 ans L=[0]*len(S) [0]*len(S) L ans=(2*ans+power[i])%mod (2*ans+power[i])%mod ans mod=10**9+7 10**9+7 mod power=[1]*(N+3) [1]*(N+3) power S=input() input() S N=len(S) len(S) N
S=input()
L=[0]*len(S)
for i in range(len(S)):
    L[i]=int(S[i])

mod=10**9+7    
    
N=len(S)
power=[1]*(N+3)
for i in range(1,N+3):
    power[i]=(power[i-1]*3)%mod

    

ans=1
for i in range(N):
    if L[N-1-i]==1:
        ans=(2*ans+power[i])%mod
print(ans%mod)