L = input()[1:]
mod = 10**9 + 7

sure = 1
possible = 2
for bit in L:
    if bit == '1':
        sure = (sure * 3 + possible) % mod
        possible = possible * 2 % mod
    else:
        sure = sure * 3 % mod

ans = (sure + possible) % mod
print(ans) L = input()[1:] L input()[1:] () input 1: 1 mod = 10**9 + 7 mod 10**9 + 7 10**9 10 9 7 sure = 1 sure 1 possible = 2 possible 2 for bit in L:
    if bit == '1':
        sure = (sure * 3 + possible) % mod
        possible = possible * 2 % mod
    else:
        sure = sure * 3 % mod bit L if bit == '1':
        sure = (sure * 3 + possible) % mod
        possible = possible * 2 % mod
    else:
        sure = sure * 3 % mod bit == '1' bit '1' sure = (sure * 3 + possible) % mod sure (sure * 3 + possible) % mod sure * 3 + possible sure * 3 sure 3 possible mod possible = possible * 2 % mod possible possible * 2 % mod possible * 2 possible 2 mod sure = sure * 3 % mod sure sure * 3 % mod sure * 3 sure 3 mod ans = (sure + possible) % mod ans (sure + possible) % mod sure + possible sure possible mod print(ans) print ans sure = sure * 3 % mod sure * 3 % mod sure sure = 1 1 sure possible = possible * 2 % mod possible * 2 % mod possible sure = (sure * 3 + possible) % mod (sure * 3 + possible) % mod sure possible = 2 2 possible mod = 10**9 + 7 10**9 + 7 mod ans = (sure + possible) % mod (sure + possible) % mod ans L = input()[1:] input()[1:] L
L = input()[1:]
mod = 10**9 + 7

sure = 1
possible = 2
for bit in L:
    if bit == '1':
        sure = (sure * 3 + possible) % mod
        possible = possible * 2 % mod
    else:
        sure = sure * 3 % mod

ans = (sure + possible) % mod
print(ans)