L = list(input())
N = len(L)
mod = 10**9+7

S = [0]*(N+1)
for i in range(N):
    if L[i] == "1":
        S[i+1] = S[i] + 1
    else:
        S[i+1] = S[i]

ans = 0
for i in range(N):
    if S[i+1] > S[i]:
        ans += pow(3, N-i-1, mod)*pow(2, S[i], mod)
        ans %= mod

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

S = [0]*(N+1)
for i in range(N):
    if L[i] == "1":
        S[i+1] = S[i] + 1
    else:
        S[i+1] = S[i]

ans = 0
for i in range(N):
    if S[i+1] > S[i]:
        ans += pow(3, N-i-1, mod)*pow(2, S[i], mod)
        ans %= mod

ans += pow(2, S[-1], mod)
print(ans%mod)