MOD = 10 ** 9 + 7

l = input()
p = len(l)
dp = [[0, 0] for _ in range(p)]
dp[0] = [1, 2]

for i, s in enumerate(l[1:], start = 1):
    if s == "1":
        dp[i][0] = dp[i - 1][0] * 3 + dp[i - 1][1]
        dp[i][1] = dp[i - 1][1] * 2
    else:
        dp[i][0] = dp[i - 1][0] * 3
        dp[i][1] = dp[i - 1][1]
    dp[i][0] %= MOD
    dp[i][1] %= MOD
ans = sum(dp[-1])
print(ans % MOD) MOD = 10 ** 9 + 7 MOD 10 ** 9 + 7 10 ** 9 10 9 7 l = input() l input() input p = len(l) p len(l) len l [0, 0] for _ in range(p) for _ in range(p) _ range(p) range p for _ in range(p) [0, 0] 0 0 dp = [[0, 0] for _ in range(p)] dp [[0, 0] for _ in range(p)] dp[0] = [1, 2] dp[0] dp 0 [1, 2] 1 2 for i, s in enumerate(l[1:], start = 1):
    if s == "1":
        dp[i][0] = dp[i - 1][0] * 3 + dp[i - 1][1]
        dp[i][1] = dp[i - 1][1] * 2
    else:
        dp[i][0] = dp[i - 1][0] * 3
        dp[i][1] = dp[i - 1][1]
    dp[i][0] %= MOD
    dp[i][1] %= MOD i s enumerate(l[1:], start = 1) enumerate l[1:] l 1: 1 start = 1 start 1 if s == "1":
        dp[i][0] = dp[i - 1][0] * 3 + dp[i - 1][1]
        dp[i][1] = dp[i - 1][1] * 2
    else:
        dp[i][0] = dp[i - 1][0] * 3
        dp[i][1] = dp[i - 1][1]
     s == "1" s "1" dp[i][0] = dp[i - 1][0] * 3 + dp[i - 1][1] dp[i][0] [i] dp i 0 dp[i - 1][0] * 3 + dp[i - 1][1] dp[i - 1][0] * 3 dp[i - 1][0] [i - 1] dp i - 1 i 1 0 3 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][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 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 = sum(dp[-1]) ans sum(dp[-1]) sum dp[-1] dp -1 print(ans % MOD) print ans % MOD ans MOD l = input() input() l ans = sum(dp[-1]) sum(dp[-1]) ans dp = [[0, 0] for _ in range(p)] [[0, 0] for _ in range(p)] dp MOD = 10 ** 9 + 7 10 ** 9 + 7 MOD p = len(l) len(l) p
MOD = 10 ** 9 + 7

l = input()
p = len(l)
dp = [[0, 0] for _ in range(p)]
dp[0] = [1, 2]

for i, s in enumerate(l[1:], start = 1):
    if s == "1":
        dp[i][0] = dp[i - 1][0] * 3 + dp[i - 1][1]
        dp[i][1] = dp[i - 1][1] * 2
    else:
        dp[i][0] = dp[i - 1][0] * 3
        dp[i][1] = dp[i - 1][1]
    dp[i][0] %= MOD
    dp[i][1] %= MOD
ans = sum(dp[-1])
print(ans % MOD)