import sys
input = sys.stdin.readline
from collections import *

S = input()[:-1]
L = len(S)
dp = [[0]*2 for _ in range(L+1)]
dp[0][0] = 1
MOD = 10**9+7

for i in range(L):
    if S[i]=='0':
        dp[i+1][0] = dp[i][0]%MOD
        dp[i+1][1] = 3*dp[i][1]%MOD
    else:
        dp[i+1][0] = 2*dp[i][0]%MOD
        dp[i+1][1] = (dp[i][0]+3*dp[i][1])%MOD
    
print(sum(dp[L])%MOD) import sys sys input = sys.stdin.readline input sys.stdin.readline sys.stdin sys stdin readline from collections import * S = input()[:-1] S input()[:-1] () input :-1 -1 L = len(S) L len(S) len S [0]*2 for _ in range(L+1) for _ in range(L+1) _ range(L+1) range L+1 L 1 for _ in range(L+1) [0]*2 [0] 0 2 dp = [[0]*2 for _ in range(L+1)] dp [[0]*2 for _ in range(L+1)] dp[0][0] = 1 dp[0][0] [0] dp 0 0 1 MOD = 10**9+7 MOD 10**9+7 10**9 10 9 7 for i in range(L):
    if S[i]=='0':
        dp[i+1][0] = dp[i][0]%MOD
        dp[i+1][1] = 3*dp[i][1]%MOD
    else:
        dp[i+1][0] = 2*dp[i][0]%MOD
        dp[i+1][1] = (dp[i][0]+3*dp[i][1])%MOD
     i range(L) range L if S[i]=='0':
        dp[i+1][0] = dp[i][0]%MOD
        dp[i+1][1] = 3*dp[i][1]%MOD
    else:
        dp[i+1][0] = 2*dp[i][0]%MOD
        dp[i+1][1] = (dp[i][0]+3*dp[i][1])%MOD
     S[i]=='0' S[i] S i '0' dp[i+1][0] = dp[i][0]%MOD dp[i+1][0] [i+1] dp i+1 i 1 0 dp[i][0]%MOD dp[i][0] [i] dp i 0 MOD dp[i+1][1] = 3*dp[i][1]%MOD dp[i+1][1] [i+1] dp i+1 i 1 1 3*dp[i][1]%MOD 3*dp[i][1] 3 dp[i][1] [i] dp i 1 MOD dp[i+1][0] = 2*dp[i][0]%MOD dp[i+1][0] [i+1] dp i+1 i 1 0 2*dp[i][0]%MOD 2*dp[i][0] 2 dp[i][0] [i] dp i 0 MOD dp[i+1][1] = (dp[i][0]+3*dp[i][1])%MOD dp[i+1][1] [i+1] dp i+1 i 1 1 (dp[i][0]+3*dp[i][1])%MOD dp[i][0]+3*dp[i][1] dp[i][0] [i] dp i 0 3*dp[i][1] 3 dp[i][1] [i] dp i 1 MOD print(sum(dp[L])%MOD) print sum(dp[L])%MOD sum(dp[L]) sum dp[L] dp L MOD input = sys.stdin.readline sys.stdin.readline input MOD = 10**9+7 10**9+7 MOD L = len(S) len(S) L dp = [[0]*2 for _ in range(L+1)] [[0]*2 for _ in range(L+1)] dp S = input()[:-1] input()[:-1] S
import sys
input = sys.stdin.readline
from collections import *

S = input()[:-1]
L = len(S)
dp = [[0]*2 for _ in range(L+1)]
dp[0][0] = 1
MOD = 10**9+7

for i in range(L):
    if S[i]=='0':
        dp[i+1][0] = dp[i][0]%MOD
        dp[i+1][1] = 3*dp[i][1]%MOD
    else:
        dp[i+1][0] = 2*dp[i][0]%MOD
        dp[i+1][1] = (dp[i][0]+3*dp[i][1])%MOD
    
print(sum(dp[L])%MOD)