MOD = 10**9+7
l = input()
n = len(l)

dp = [ [0]*2 for _ in range(n+1) ]
dp[0][0] = 1 # same
dp[0][1] = 0 # smaller

for i in range(n):
    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][0]%=MOD
    dp[i+1][1]%=MOD

ans = dp[n][0] + dp[n][1]
print(ans%MOD) MOD = 10**9+7 MOD 10**9+7 10**9 10 9 7 l = input() l input() input n = len(l) n len(l) len l [0]*2 for _ in range(n+1) for _ in range(n+1) _ range(n+1) range n+1 n 1 for _ in range(n+1) [0]*2 [0] 0 2 dp = [ [0]*2 for _ in range(n+1) ] dp [ [0]*2 for _ in range(n+1) ] dp[0][0] = 1 dp[0][0] [0] dp 0 0 1 dp[0][1] = 0 dp[0][1] [0] dp 0 1 0 for i in range(n):
    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][0]%=MOD
    dp[i+1][1]%=MOD i range(n) range n 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][0]%=MOD dp[i+1][0] [i+1] dp i+1 i 1 0 MOD dp[i+1][1]%=MOD dp[i+1][1] [i+1] dp i+1 i 1 1 MOD ans = dp[n][0] + dp[n][1] ans dp[n][0] + dp[n][1] dp[n][0] [n] dp n 0 dp[n][1] [n] dp n 1 print(ans%MOD) print ans%MOD ans MOD dp = [ [0]*2 for _ in range(n+1) ] [ [0]*2 for _ in range(n+1) ] dp MOD = 10**9+7 10**9+7 MOD ans = dp[n][0] + dp[n][1] dp[n][0] + dp[n][1] ans n = len(l) len(l) n l = input() input() l
MOD = 10**9+7
l = input()
n = len(l)

dp = [ [0]*2 for _ in range(n+1) ]
dp[0][0] = 1 # same
dp[0][1] = 0 # smaller

for i in range(n):
    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][0]%=MOD
    dp[i+1][1]%=MOD

ans = dp[n][0] + dp[n][1]
print(ans%MOD)