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

smaller = [0] * N
not_smaller = [0] * N

smaller[0] = 1
not_smaller[0] = 2

for i in range(1, N):
    if L[i] == "1":
        smaller[i] = 3 * smaller[i - 1] + not_smaller[i - 1]
        not_smaller[i] = 2 * not_smaller[i - 1]
    elif L[i] == "0":
        smaller[i] = 3 * smaller[i - 1]
        not_smaller[i] = not_smaller[i - 1]

    smaller[i] %= MOD
    not_smaller[i] %= MOD

ans = (smaller[-1] + not_smaller[-1]) % MOD
print(ans) L = input() L input() input N = len(L) N len(L) len L MOD = 10**9 + 7 MOD 10**9 + 7 10**9 10 9 7 smaller = [0] * N smaller [0] * N [0] 0 N not_smaller = [0] * N not_smaller [0] * N [0] 0 N smaller[0] = 1 smaller[0] smaller 0 1 not_smaller[0] = 2 not_smaller[0] not_smaller 0 2 for i in range(1, N):
    if L[i] == "1":
        smaller[i] = 3 * smaller[i - 1] + not_smaller[i - 1]
        not_smaller[i] = 2 * not_smaller[i - 1]
    elif L[i] == "0":
        smaller[i] = 3 * smaller[i - 1]
        not_smaller[i] = not_smaller[i - 1]

    smaller[i] %= MOD
    not_smaller[i] %= MOD i range(1, N) range 1 N if L[i] == "1":
        smaller[i] = 3 * smaller[i - 1] + not_smaller[i - 1]
        not_smaller[i] = 2 * not_smaller[i - 1]
    elif L[i] == "0":
        smaller[i] = 3 * smaller[i - 1]
        not_smaller[i] = not_smaller[i - 1]

     L[i] == "1" L[i] L i "1" smaller[i] = 3 * smaller[i - 1] + not_smaller[i - 1] smaller[i] smaller i 3 * smaller[i - 1] + not_smaller[i - 1] 3 * smaller[i - 1] 3 smaller[i - 1] smaller i - 1 i 1 not_smaller[i - 1] not_smaller i - 1 i 1 not_smaller[i] = 2 * not_smaller[i - 1] not_smaller[i] not_smaller i 2 * not_smaller[i - 1] 2 not_smaller[i - 1] not_smaller i - 1 i 1 elif L[i] == "0":
        smaller[i] = 3 * smaller[i - 1]
        not_smaller[i] = not_smaller[i - 1]

     L[i] == "0" L[i] L i "0" smaller[i] = 3 * smaller[i - 1] smaller[i] smaller i 3 * smaller[i - 1] 3 smaller[i - 1] smaller i - 1 i 1 not_smaller[i] = not_smaller[i - 1] not_smaller[i] not_smaller i not_smaller[i - 1] not_smaller i - 1 i 1 smaller[i] %= MOD smaller[i] smaller i MOD not_smaller[i] %= MOD not_smaller[i] not_smaller i MOD ans = (smaller[-1] + not_smaller[-1]) % MOD ans (smaller[-1] + not_smaller[-1]) % MOD smaller[-1] + not_smaller[-1] smaller[-1] smaller -1 not_smaller[-1] not_smaller -1 MOD print(ans) print ans L = input() input() L not_smaller = [0] * N [0] * N not_smaller N = len(L) len(L) N MOD = 10**9 + 7 10**9 + 7 MOD ans = (smaller[-1] + not_smaller[-1]) % MOD (smaller[-1] + not_smaller[-1]) % MOD ans smaller = [0] * N [0] * N smaller
L = input()
N = len(L)
MOD = 10**9 + 7

smaller = [0] * N
not_smaller = [0] * N

smaller[0] = 1
not_smaller[0] = 2

for i in range(1, N):
    if L[i] == "1":
        smaller[i] = 3 * smaller[i - 1] + not_smaller[i - 1]
        not_smaller[i] = 2 * not_smaller[i - 1]
    elif L[i] == "0":
        smaller[i] = 3 * smaller[i - 1]
        not_smaller[i] = not_smaller[i - 1]

    smaller[i] %= MOD
    not_smaller[i] %= MOD

ans = (smaller[-1] + not_smaller[-1]) % MOD
print(ans)
