s = input() #sys.stdin.readlineは最後が改行
n = len(s)
p=10**9+7

dp = [[0]*2 for _ in range(n)]

dp[0][0]=2
dp[0][1]=1


# dp[i][smaller]:i番目以前の商品を見たときの組み合わせの数。L以下が確定かどうか

for i in range(1,n):
        if s[i]=='1':
            dp[i][0] = (dp[i-1][0]*2)%p
            dp[i][1] = (dp[i-1][1]*3)%p + (dp[i-1][0])%p
        else:
            dp[i][0] = dp[i-1][0]*1
            dp[i][1] = (dp[i-1][1]*3)%p

print((dp[n-1][0]+dp[n-1][1])%p)
 s = input() s input() input n = len(s) n len(s) len s p=10**9+7 p 10**9+7 10**9 10 9 7 [0]*2 for _ in range(n) for _ in range(n) _ range(n) range n for _ in range(n) [0]*2 [0] 0 2 dp = [[0]*2 for _ in range(n)] dp [[0]*2 for _ in range(n)] dp[0][0]=2 dp[0][0] [0] dp 0 0 2 dp[0][1]=1 dp[0][1] [0] dp 0 1 1 for i in range(1,n):
        if s[i]=='1':
            dp[i][0] = (dp[i-1][0]*2)%p
            dp[i][1] = (dp[i-1][1]*3)%p + (dp[i-1][0])%p
        else:
            dp[i][0] = dp[i-1][0]*1
            dp[i][1] = (dp[i-1][1]*3)%p i range(1,n) range 1 n if s[i]=='1':
            dp[i][0] = (dp[i-1][0]*2)%p
            dp[i][1] = (dp[i-1][1]*3)%p + (dp[i-1][0])%p
        else:
            dp[i][0] = dp[i-1][0]*1
            dp[i][1] = (dp[i-1][1]*3)%p s[i]=='1' s[i] s i '1' dp[i][0] = (dp[i-1][0]*2)%p dp[i][0] [i] dp i 0 (dp[i-1][0]*2)%p dp[i-1][0]*2 dp[i-1][0] [i-1] dp i-1 i 1 0 2 p dp[i][1] = (dp[i-1][1]*3)%p + (dp[i-1][0])%p dp[i][1] [i] dp i 1 (dp[i-1][1]*3)%p + (dp[i-1][0])%p (dp[i-1][1]*3)%p dp[i-1][1]*3 dp[i-1][1] [i-1] dp i-1 i 1 1 3 p (dp[i-1][0])%p dp[i-1][0] [i-1] dp i-1 i 1 0 p dp[i][0] = dp[i-1][0]*1 dp[i][0] [i] dp i 0 dp[i-1][0]*1 dp[i-1][0] [i-1] dp i-1 i 1 0 1 dp[i][1] = (dp[i-1][1]*3)%p dp[i][1] [i] dp i 1 (dp[i-1][1]*3)%p dp[i-1][1]*3 dp[i-1][1] [i-1] dp i-1 i 1 1 3 p print((dp[n-1][0]+dp[n-1][1])%p) print (dp[n-1][0]+dp[n-1][1])%p dp[n-1][0]+dp[n-1][1] dp[n-1][0] [n-1] dp n-1 n 1 0 dp[n-1][1] [n-1] dp n-1 n 1 1 p n = len(s) len(s) n dp = [[0]*2 for _ in range(n)] [[0]*2 for _ in range(n)] dp p=10**9+7 10**9+7 p s = input() input() s
s = input() #sys.stdin.readlineは最後が改行
n = len(s)
p=10**9+7

dp = [[0]*2 for _ in range(n)]

dp[0][0]=2
dp[0][1]=1


# dp[i][smaller]:i番目以前の商品を見たときの組み合わせの数。L以下が確定かどうか

for i in range(1,n):
        if s[i]=='1':
            dp[i][0] = (dp[i-1][0]*2)%p
            dp[i][1] = (dp[i-1][1]*3)%p + (dp[i-1][0])%p
        else:
            dp[i][0] = dp[i-1][0]*1
            dp[i][1] = (dp[i-1][1]*3)%p

print((dp[n-1][0]+dp[n-1][1])%p)

