# -*- coding: utf-8 -*-
import sys


L = input()
#%%
MOD = 10**9+7


dp = [[0]*2 for _ in range(len(L))]
dp[0][0] = 1
dp[0][1] = 2
for i,l in enumerate(L[1:]):
    dp[i+1][0] = (3*dp[i][0] + int(l)*dp[i][1])%MOD
    dp[i+1][1] = ((1+int(l))*dp[i][1])%MOD
print((dp[-1][0]+dp[-1][1])%MOD) import sys sys L = input() L input() input MOD = 10**9+7 MOD 10**9+7 10**9 10 9 7 [0]*2 for _ in range(len(L)) for _ in range(len(L)) _ range(len(L)) range len(L) len L for _ in range(len(L)) [0]*2 [0] 0 2 dp = [[0]*2 for _ in range(len(L))] dp [[0]*2 for _ in range(len(L))] dp[0][0] = 1 dp[0][0] [0] dp 0 0 1 dp[0][1] = 2 dp[0][1] [0] dp 0 1 2 for i,l in enumerate(L[1:]):
    dp[i+1][0] = (3*dp[i][0] + int(l)*dp[i][1])%MOD
    dp[i+1][1] = ((1+int(l))*dp[i][1])%MOD i l enumerate(L[1:]) enumerate L[1:] L 1: 1 dp[i+1][0] = (3*dp[i][0] + int(l)*dp[i][1])%MOD dp[i+1][0] [i+1] dp i+1 i 1 0 (3*dp[i][0] + int(l)*dp[i][1])%MOD 3*dp[i][0] + int(l)*dp[i][1] 3*dp[i][0] 3 dp[i][0] [i] dp i 0 int(l)*dp[i][1] int(l) int l dp[i][1] [i] dp i 1 MOD dp[i+1][1] = ((1+int(l))*dp[i][1])%MOD dp[i+1][1] [i+1] dp i+1 i 1 1 ((1+int(l))*dp[i][1])%MOD (1+int(l))*dp[i][1] 1+int(l) 1 int(l) int l dp[i][1] [i] dp i 1 MOD print((dp[-1][0]+dp[-1][1])%MOD) print (dp[-1][0]+dp[-1][1])%MOD dp[-1][0]+dp[-1][1] dp[-1][0] [-1] dp -1 0 dp[-1][1] [-1] dp -1 1 MOD MOD = 10**9+7 10**9+7 MOD L = input() input() L dp = [[0]*2 for _ in range(len(L))] [[0]*2 for _ in range(len(L))] dp
# -*- coding: utf-8 -*-
import sys


L = input()
#%%
MOD = 10**9+7


dp = [[0]*2 for _ in range(len(L))]
dp[0][0] = 1
dp[0][1] = 2
for i,l in enumerate(L[1:]):
    dp[i+1][0] = (3*dp[i][0] + int(l)*dp[i][1])%MOD
    dp[i+1][1] = ((1+int(l))*dp[i][1])%MOD
print((dp[-1][0]+dp[-1][1])%MOD)