mod=10**9+7
l=input()
bit=[int(i) for i in l]
m=len(bit)
#num1=sum(bit)
#print(bit)
#print(m)
#print(num1)
#ans=0
#ans+=(pow(3,m-1,mod))
#最上位bitの時
#ans+=(2*pow(2,num1-1,mod))
#print(ans%mod)

#適当にやりすぎたけど、桁DPジャン
#小さい方と同じ方
dp=[[0,0] for i in range(m)]
dp[0]=[1,2]
for i in range(m-1):
    dp[i+1][0]=3*dp[i][0]%mod
    if bit[i+1]==0:
        dp[i+1][1]+=dp[i][1]
        dp[i+1][1]%=mod
    else:
        dp[i+1][0]+=dp[i][1]
        dp[i+1][1]+=(2*dp[i][1])
        dp[i+1][0]%=mod
        dp[i+1][1]%=mod
print(sum(dp[m-1])%mod) mod=10**9+7 mod 10**9+7 10**9 10 9 7 l=input() l input() input int(i) for i in l for i in l i l for i in l int(i) int i bit=[int(i) for i in l] bit [int(i) for i in l] m=len(bit) m len(bit) len bit [0,0] for i in range(m) for i in range(m) i range(m) range m for i in range(m) [0,0] 0 0 dp=[[0,0] for i in range(m)] dp [[0,0] for i in range(m)] dp[0]=[1,2] dp[0] dp 0 [1,2] 1 2 for i in range(m-1):
    dp[i+1][0]=3*dp[i][0]%mod
    if bit[i+1]==0:
        dp[i+1][1]+=dp[i][1]
        dp[i+1][1]%=mod
    else:
        dp[i+1][0]+=dp[i][1]
        dp[i+1][1]+=(2*dp[i][1])
        dp[i+1][0]%=mod
        dp[i+1][1]%=mod i range(m-1) range m-1 m 1 dp[i+1][0]=3*dp[i][0]%mod dp[i+1][0] [i+1] dp i+1 i 1 0 3*dp[i][0]%mod 3*dp[i][0] 3 dp[i][0] [i] dp i 0 mod if bit[i+1]==0:
        dp[i+1][1]+=dp[i][1]
        dp[i+1][1]%=mod
    else:
        dp[i+1][0]+=dp[i][1]
        dp[i+1][1]+=(2*dp[i][1])
        dp[i+1][0]%=mod
        dp[i+1][1]%=mod bit[i+1]==0 bit[i+1] bit i+1 i 1 0 dp[i+1][1]+=dp[i][1] dp[i+1][1] [i+1] dp i+1 i 1 1 dp[i][1] [i] dp i 1 dp[i+1][1]%=mod dp[i+1][1] [i+1] dp i+1 i 1 1 mod dp[i+1][0]+=dp[i][1] dp[i+1][0] [i+1] dp i+1 i 1 0 dp[i][1] [i] dp i 1 dp[i+1][1]+=(2*dp[i][1]) dp[i+1][1] [i+1] dp i+1 i 1 1 2*dp[i][1] 2 dp[i][1] [i] dp i 1 dp[i+1][0]%=mod dp[i+1][0] [i+1] dp i+1 i 1 0 mod dp[i+1][1]%=mod dp[i+1][1] [i+1] dp i+1 i 1 1 mod print(sum(dp[m-1])%mod) print sum(dp[m-1])%mod sum(dp[m-1]) sum dp[m-1] dp m-1 m 1 mod mod=10**9+7 10**9+7 mod l=input() input() l m=len(bit) len(bit) m dp=[[0,0] for i in range(m)] [[0,0] for i in range(m)] dp bit=[int(i) for i in l] [int(i) for i in l] bit
mod=10**9+7
l=input()
bit=[int(i) for i in l]
m=len(bit)
#num1=sum(bit)
#print(bit)
#print(m)
#print(num1)
#ans=0
#ans+=(pow(3,m-1,mod))
#最上位bitの時
#ans+=(2*pow(2,num1-1,mod))
#print(ans%mod)

#適当にやりすぎたけど、桁DPジャン
#小さい方と同じ方
dp=[[0,0] for i in range(m)]
dp[0]=[1,2]
for i in range(m-1):
    dp[i+1][0]=3*dp[i][0]%mod
    if bit[i+1]==0:
        dp[i+1][1]+=dp[i][1]
        dp[i+1][1]%=mod
    else:
        dp[i+1][0]+=dp[i][1]
        dp[i+1][1]+=(2*dp[i][1])
        dp[i+1][0]%=mod
        dp[i+1][1]%=mod
print(sum(dp[m-1])%mod)