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

n = len(l)

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

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

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

    dp[i][0] %= mod
    dp[i][1] %= mod

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

    dp[i][0] %= mod
    dp[i][1] %= mod i range(1,n) range 1 n dp[i][0] = dp[i-1][0]*3 dp[i][0] [i] dp i 0 dp[i-1][0]*3 dp[i-1][0] [i-1] dp i-1 i 1 0 3 if l[i]=='1':
        dp[i][0] += dp[i-1][1]
        dp[i][1] = dp[i-1][1]*2
    else:
        dp[i][1] = dp[i-1][1]

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

n = len(l)

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

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

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

    dp[i][0] %= mod
    dp[i][1] %= mod

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