S = input()
C = 10**9+7
T = S[::-1]
N = len(S)
dp = [0]*N
dp[0] = 1+2*(int(T[0]))

for i in range(1, N):
    if T[i] == '0':
        dp[i] = dp[i-1]
    else:
        dp[i] = (pow(3, i, C)+2*dp[i-1]) % C
print(dp[-1]) S = input() S input() input C = 10**9+7 C 10**9+7 10**9 10 9 7 T = S[::-1] T S[::-1] S ::-1 -1 N = len(S) N len(S) len S dp = [0]*N dp [0]*N [0] 0 N dp[0] = 1+2*(int(T[0])) dp[0] dp 0 1+2*(int(T[0])) 1 2*(int(T[0])) 2 int(T[0]) int T[0] T 0 for i in range(1, N):
    if T[i] == '0':
        dp[i] = dp[i-1]
    else:
        dp[i] = (pow(3, i, C)+2*dp[i-1]) % C i range(1, N) range 1 N if T[i] == '0':
        dp[i] = dp[i-1]
    else:
        dp[i] = (pow(3, i, C)+2*dp[i-1]) % C T[i] == '0' T[i] T i '0' dp[i] = dp[i-1] dp[i] dp i dp[i-1] dp i-1 i 1 dp[i] = (pow(3, i, C)+2*dp[i-1]) % C dp[i] dp i (pow(3, i, C)+2*dp[i-1]) % C pow(3, i, C)+2*dp[i-1] pow(3, i, C) pow 3 i C 2*dp[i-1] 2 dp[i-1] dp i-1 i 1 C print(dp[-1]) print dp[-1] dp -1 C = 10**9+7 10**9+7 C T = S[::-1] S[::-1] T N = len(S) len(S) N dp = [0]*N [0]*N dp S = input() input() S
S = input()
C = 10**9+7
T = S[::-1]
N = len(S)
dp = [0]*N
dp[0] = 1+2*(int(T[0]))

for i in range(1, N):
    if T[i] == '0':
        dp[i] = dp[i-1]
    else:
        dp[i] = (pow(3, i, C)+2*dp[i-1]) % C
print(dp[-1])