MOD = 10 ** 9 + 7

L = list(input())

N = len(L)

OK = [0] * (N + 1)
JUST = [0] * (N + 1)
JUST[0] = 1

for i in range(N):
    if L[i] == '1':
        OK[i + 1] = (OK[i] * 3 + JUST[i]) % MOD
        JUST[i + 1] = (JUST[i] * 2) % MOD
    else:
        OK[i + 1] = (OK[i] * 3) % MOD
        JUST[i + 1] = (JUST[i]) % MOD

print ((OK[-1] + JUST[-1]) % MOD) MOD = 10 ** 9 + 7 MOD 10 ** 9 + 7 10 ** 9 10 9 7 L = list(input()) L list(input()) list input() input N = len(L) N len(L) len L OK = [0] * (N + 1) OK [0] * (N + 1) [0] 0 N + 1 N 1 JUST = [0] * (N + 1) JUST [0] * (N + 1) [0] 0 N + 1 N 1 JUST[0] = 1 JUST[0] JUST 0 1 for i in range(N):
    if L[i] == '1':
        OK[i + 1] = (OK[i] * 3 + JUST[i]) % MOD
        JUST[i + 1] = (JUST[i] * 2) % MOD
    else:
        OK[i + 1] = (OK[i] * 3) % MOD
        JUST[i + 1] = (JUST[i]) % MOD i range(N) range N if L[i] == '1':
        OK[i + 1] = (OK[i] * 3 + JUST[i]) % MOD
        JUST[i + 1] = (JUST[i] * 2) % MOD
    else:
        OK[i + 1] = (OK[i] * 3) % MOD
        JUST[i + 1] = (JUST[i]) % MOD L[i] == '1' L[i] L i '1' OK[i + 1] = (OK[i] * 3 + JUST[i]) % MOD OK[i + 1] OK i + 1 i 1 (OK[i] * 3 + JUST[i]) % MOD OK[i] * 3 + JUST[i] OK[i] * 3 OK[i] OK i 3 JUST[i] JUST i MOD JUST[i + 1] = (JUST[i] * 2) % MOD JUST[i + 1] JUST i + 1 i 1 (JUST[i] * 2) % MOD JUST[i] * 2 JUST[i] JUST i 2 MOD OK[i + 1] = (OK[i] * 3) % MOD OK[i + 1] OK i + 1 i 1 (OK[i] * 3) % MOD OK[i] * 3 OK[i] OK i 3 MOD JUST[i + 1] = (JUST[i]) % MOD JUST[i + 1] JUST i + 1 i 1 (JUST[i]) % MOD JUST[i] JUST i MOD print ((OK[-1] + JUST[-1]) % MOD) print (OK[-1] + JUST[-1]) % MOD OK[-1] + JUST[-1] OK[-1] OK -1 JUST[-1] JUST -1 MOD JUST = [0] * (N + 1) [0] * (N + 1) JUST MOD = 10 ** 9 + 7 10 ** 9 + 7 MOD OK = [0] * (N + 1) [0] * (N + 1) OK N = len(L) len(L) N L = list(input()) list(input()) L
MOD = 10 ** 9 + 7

L = list(input())

N = len(L)

OK = [0] * (N + 1)
JUST = [0] * (N + 1)
JUST[0] = 1

for i in range(N):
    if L[i] == '1':
        OK[i + 1] = (OK[i] * 3 + JUST[i]) % MOD
        JUST[i + 1] = (JUST[i] * 2) % MOD
    else:
        OK[i + 1] = (OK[i] * 3) % MOD
        JUST[i + 1] = (JUST[i]) % MOD

print ((OK[-1] + JUST[-1]) % MOD)