import numpy as np

L = input()
mod = 10**9+7

DP = np.zeros((len(L)+1, 2), int)
DP[0][0] = 1

for i in range(len(L)):
    if L[i] == '1':
        DP[i+1][0] = DP[i][0] * 2
        DP[i+1][1] = DP[i][0] + DP[i][1] * 3
    else:
        DP[i+1][0] = DP[i][0]
        DP[i+1][1] = DP[i][1] * 3
    DP[i+1] %= mod

print(sum(DP[-1]) % mod) import numpy as np numpy L = input() L input() input mod = 10**9+7 mod 10**9+7 10**9 10 9 7 DP = np.zeros((len(L)+1, 2), int) DP np.zeros((len(L)+1, 2), int) np.zeros np zeros (len(L)+1, 2) len(L)+1 len(L) len L 1 2 int DP[0][0] = 1 DP[0][0] [0] DP 0 0 1 for i in range(len(L)):
    if L[i] == '1':
        DP[i+1][0] = DP[i][0] * 2
        DP[i+1][1] = DP[i][0] + DP[i][1] * 3
    else:
        DP[i+1][0] = DP[i][0]
        DP[i+1][1] = DP[i][1] * 3
    DP[i+1] %= mod i range(len(L)) range len(L) len L if L[i] == '1':
        DP[i+1][0] = DP[i][0] * 2
        DP[i+1][1] = DP[i][0] + DP[i][1] * 3
    else:
        DP[i+1][0] = DP[i][0]
        DP[i+1][1] = DP[i][1] * 3
     L[i] == '1' L[i] L i '1' DP[i+1][0] = DP[i][0] * 2 DP[i+1][0] [i+1] DP i+1 i 1 0 DP[i][0] * 2 DP[i][0] [i] DP i 0 2 DP[i+1][1] = DP[i][0] + DP[i][1] * 3 DP[i+1][1] [i+1] DP i+1 i 1 1 DP[i][0] + DP[i][1] * 3 DP[i][0] [i] DP i 0 DP[i][1] * 3 DP[i][1] [i] DP i 1 3 DP[i+1][0] = DP[i][0] DP[i+1][0] [i+1] DP i+1 i 1 0 DP[i][0] [i] DP i 0 DP[i+1][1] = DP[i][1] * 3 DP[i+1][1] [i+1] DP i+1 i 1 1 DP[i][1] * 3 DP[i][1] [i] DP i 1 3 DP[i+1] %= mod DP[i+1] DP i+1 i 1 mod print(sum(DP[-1]) % mod) print sum(DP[-1]) % mod sum(DP[-1]) sum DP[-1] DP -1 mod L = input() input() L mod = 10**9+7 10**9+7 mod DP = np.zeros((len(L)+1, 2), int) np.zeros((len(L)+1, 2), int) DP
import numpy as np

L = input()
mod = 10**9+7

DP = np.zeros((len(L)+1, 2), int)
DP[0][0] = 1

for i in range(len(L)):
    if L[i] == '1':
        DP[i+1][0] = DP[i][0] * 2
        DP[i+1][1] = DP[i][0] + DP[i][1] * 3
    else:
        DP[i+1][0] = DP[i][0]
        DP[i+1][1] = DP[i][1] * 3
    DP[i+1] %= mod

print(sum(DP[-1]) % mod)