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

# dp[i][flg] := 上からi番目の桁まで見た時に、L以下であることがflg（未確定/確定）であるような、条件を満たす組み合わせの通り数
dp = [[0] * 2 for i in range(len(L) + 1)]
dp[0][0] = 1
for i, l in enumerate(L, start=1):
    if l == '0':
        dp[i][0] = dp[i - 1][0]
        dp[i][1] = (3 * dp[i - 1][1]) % MOD
    else:
        dp[i][0] = (2 * dp[i - 1][0]) % MOD
        dp[i][1] = (3 * dp[i - 1][1] + dp[i - 1][0]) % MOD

print(sum(dp[-1]) % MOD) L = input() L input() input MOD = 10 ** 9 + 7 MOD 10 ** 9 + 7 10 ** 9 10 9 7 [0] * 2 for i in range(len(L) + 1) for i in range(len(L) + 1) i range(len(L) + 1) range len(L) + 1 len(L) len L 1 for i in range(len(L) + 1) [0] * 2 [0] 0 2 dp = [[0] * 2 for i in range(len(L) + 1)] dp [[0] * 2 for i in range(len(L) + 1)] dp[0][0] = 1 dp[0][0] [0] dp 0 0 1 for i, l in enumerate(L, start=1):
    if l == '0':
        dp[i][0] = dp[i - 1][0]
        dp[i][1] = (3 * dp[i - 1][1]) % MOD
    else:
        dp[i][0] = (2 * dp[i - 1][0]) % MOD
        dp[i][1] = (3 * dp[i - 1][1] + dp[i - 1][0]) % MOD i l enumerate(L, start=1) enumerate L start=1 start 1 if l == '0':
        dp[i][0] = dp[i - 1][0]
        dp[i][1] = (3 * dp[i - 1][1]) % MOD
    else:
        dp[i][0] = (2 * dp[i - 1][0]) % MOD
        dp[i][1] = (3 * dp[i - 1][1] + dp[i - 1][0]) % MOD l == '0' l '0' dp[i][0] = dp[i - 1][0] dp[i][0] [i] dp i 0 dp[i - 1][0] [i - 1] dp i - 1 i 1 0 dp[i][1] = (3 * dp[i - 1][1]) % MOD dp[i][1] [i] dp i 1 (3 * dp[i - 1][1]) % MOD 3 * dp[i - 1][1] 3 dp[i - 1][1] [i - 1] dp i - 1 i 1 1 MOD dp[i][0] = (2 * dp[i - 1][0]) % MOD dp[i][0] [i] dp i 0 (2 * dp[i - 1][0]) % MOD 2 * dp[i - 1][0] 2 dp[i - 1][0] [i - 1] dp i - 1 i 1 0 MOD dp[i][1] = (3 * dp[i - 1][1] + dp[i - 1][0]) % MOD dp[i][1] [i] dp i 1 (3 * dp[i - 1][1] + dp[i - 1][0]) % MOD 3 * dp[i - 1][1] + dp[i - 1][0] 3 * dp[i - 1][1] 3 dp[i - 1][1] [i - 1] dp i - 1 i 1 1 dp[i - 1][0] [i - 1] dp i - 1 i 1 0 MOD print(sum(dp[-1]) % MOD) print sum(dp[-1]) % MOD sum(dp[-1]) sum dp[-1] dp -1 MOD L = input() input() L dp = [[0] * 2 for i in range(len(L) + 1)] [[0] * 2 for i in range(len(L) + 1)] dp MOD = 10 ** 9 + 7 10 ** 9 + 7 MOD
L = input()
MOD = 10 ** 9 + 7

# dp[i][flg] := 上からi番目の桁まで見た時に、L以下であることがflg（未確定/確定）であるような、条件を満たす組み合わせの通り数
dp = [[0] * 2 for i in range(len(L) + 1)]
dp[0][0] = 1
for i, l in enumerate(L, start=1):
    if l == '0':
        dp[i][0] = dp[i - 1][0]
        dp[i][1] = (3 * dp[i - 1][1]) % MOD
    else:
        dp[i][0] = (2 * dp[i - 1][0]) % MOD
        dp[i][1] = (3 * dp[i - 1][1] + dp[i - 1][0]) % MOD

print(sum(dp[-1]) % MOD)
