L = [int(i) for i in input()]
l = len(L)

# L以下の整数は「上からi桁目まで同じで、それ以降違う」で考える。　あるL以下の整数=A+B
# L[i]=0のときAとBの桁は(0,0), L[i]=1のときAとBの桁は(0,1)(1,0)のどちらか
mod = 10 ** 9 + 7
answer = 0
mod_pow = [0] * (l + 1)
prev = 1
mod_pow[0] = 1


for i in range(1, l + 1):
    prev *= 3
    prev %= mod
    mod_pow[i] = prev

prev = 1
for i, j in enumerate(L, 1):
    if j == 0:
        continue
    answer += prev * mod_pow[l - i]
    answer %= mod
    prev *= 2
    prev %= mod

answer += prev
answer %= mod
print(answer) int(i) for i in input() for i in input() i input() input for i in input() int(i) int i L = [int(i) for i in input()] L [int(i) for i in input()] l = len(L) l len(L) len L mod = 10 ** 9 + 7 mod 10 ** 9 + 7 10 ** 9 10 9 7 answer = 0 answer 0 mod_pow = [0] * (l + 1) mod_pow [0] * (l + 1) [0] 0 l + 1 l 1 prev = 1 prev 1 mod_pow[0] = 1 mod_pow[0] mod_pow 0 1 for i in range(1, l + 1):
    prev *= 3
    prev %= mod
    mod_pow[i] = prev i range(1, l + 1) range 1 l + 1 l 1 prev *= 3 prev 3 prev %= mod prev mod mod_pow[i] = prev mod_pow[i] mod_pow i prev prev = 1 prev 1 for i, j in enumerate(L, 1):
    if j == 0:
        continue
    answer += prev * mod_pow[l - i]
    answer %= mod
    prev *= 2
    prev %= mod i j enumerate(L, 1) enumerate L 1 if j == 0:
        continue
     j == 0 j 0 continue answer += prev * mod_pow[l - i] answer prev * mod_pow[l - i] prev mod_pow[l - i] mod_pow l - i l i answer %= mod answer mod prev *= 2 prev 2 prev %= mod prev mod answer += prev answer prev answer %= mod answer mod print(answer) print answer answer = 0 0 answer prev %= mod mod prev l = len(L) len(L) l L = [int(i) for i in input()] [int(i) for i in input()] L mod_pow = [0] * (l + 1) [0] * (l + 1) mod_pow answer %= mod mod answer answer %= mod mod answer prev = 1 1 prev prev %= mod mod prev prev *= 2 2 prev prev = 1 1 prev prev *= 3 3 prev answer += prev * mod_pow[l - i] prev * mod_pow[l - i] answer mod = 10 ** 9 + 7 10 ** 9 + 7 mod answer += prev prev answer
L = [int(i) for i in input()]
l = len(L)

# L以下の整数は「上からi桁目まで同じで、それ以降違う」で考える。　あるL以下の整数=A+B
# L[i]=0のときAとBの桁は(0,0), L[i]=1のときAとBの桁は(0,1)(1,0)のどちらか
mod = 10 ** 9 + 7
answer = 0
mod_pow = [0] * (l + 1)
prev = 1
mod_pow[0] = 1


for i in range(1, l + 1):
    prev *= 3
    prev %= mod
    mod_pow[i] = prev

prev = 1
for i, j in enumerate(L, 1):
    if j == 0:
        continue
    answer += prev * mod_pow[l - i]
    answer %= mod
    prev *= 2
    prev %= mod

answer += prev
answer %= mod
print(answer)
