# 条件は a+b = a^bよりa&b=0→各ビットごとに(1,0),(0,1),(0,0)の組み合わせのみ
# 上の方から決めていく桁DPになりそう？
# 組み合わせがどれでも良ければ上の3つ、和が0なら1通り、和が1なら上記の2パタ。
# Lは2進数表記
L = input()
keta = len(L)
mod = 10 ** 9 + 7
# dp[桁数][smaller]
dp = [[0] * 2 for _ in range(keta + 2)]
dp[0][0] = 1
for i in range(keta):
    nd = int(L[i])
    for j in range(2):
        ni = i + 1
        nj = j
        if j == 1:
            dp[ni][nj] += 3 * dp[i][j]
            dp[ni][nj] %= mod
        else:
            if nd == 0:
                dp[ni][nj] += dp[i][j]
                dp[ni][nj] %= mod
            else:  # nd==1
                dp[ni][nj] += 2 * dp[i][j]  # (1,0), (0,1)
                dp[ni][1] += dp[i][j]  # (0,0)
                dp[ni][nj] %= mod
ans = dp[keta][0] + dp[keta][1]
ans %= mod
print(ans) L = input() L input() input keta = len(L) keta len(L) len L mod = 10 ** 9 + 7 mod 10 ** 9 + 7 10 ** 9 10 9 7 [0] * 2 for _ in range(keta + 2) for _ in range(keta + 2) _ range(keta + 2) range keta + 2 keta 2 for _ in range(keta + 2) [0] * 2 [0] 0 2 dp = [[0] * 2 for _ in range(keta + 2)] dp [[0] * 2 for _ in range(keta + 2)] dp[0][0] = 1 dp[0][0] [0] dp 0 0 1 for i in range(keta):
    nd = int(L[i])
    for j in range(2):
        ni = i + 1
        nj = j
        if j == 1:
            dp[ni][nj] += 3 * dp[i][j]
            dp[ni][nj] %= mod
        else:
            if nd == 0:
                dp[ni][nj] += dp[i][j]
                dp[ni][nj] %= mod
            else:  # nd==1
                dp[ni][nj] += 2 * dp[i][j]  # (1,0), (0,1)
                dp[ni][1] += dp[i][j]  # (0,0)
                dp[ni][nj] %= mod i range(keta) range keta nd = int(L[i]) nd int(L[i]) int L[i] L i for j in range(2):
        ni = i + 1
        nj = j
        if j == 1:
            dp[ni][nj] += 3 * dp[i][j]
            dp[ni][nj] %= mod
        else:
            if nd == 0:
                dp[ni][nj] += dp[i][j]
                dp[ni][nj] %= mod
            else:  # nd==1
                dp[ni][nj] += 2 * dp[i][j]  # (1,0), (0,1)
                dp[ni][1] += dp[i][j]  # (0,0)
                dp[ni][nj] %= mod j range(2) range 2 ni = i + 1 ni i + 1 i 1 nj = j nj j if j == 1:
            dp[ni][nj] += 3 * dp[i][j]
            dp[ni][nj] %= mod
        else:
            if nd == 0:
                dp[ni][nj] += dp[i][j]
                dp[ni][nj] %= mod
            else:  # nd==1
                dp[ni][nj] += 2 * dp[i][j]  # (1,0), (0,1)
                dp[ni][1] += dp[i][j]  # (0,0)
                dp[ni][nj] %= mod j == 1 j 1 dp[ni][nj] += 3 * dp[i][j] dp[ni][nj] [ni] dp ni nj 3 * dp[i][j] 3 dp[i][j] [i] dp i j dp[ni][nj] %= mod dp[ni][nj] [ni] dp ni nj mod if nd == 0:
                dp[ni][nj] += dp[i][j]
                dp[ni][nj] %= mod
            else:  # nd==1
                dp[ni][nj] += 2 * dp[i][j]  # (1,0), (0,1)
                dp[ni][1] += dp[i][j]  # (0,0)
                dp[ni][nj] %= mod nd == 0 nd 0 dp[ni][nj] += dp[i][j] dp[ni][nj] [ni] dp ni nj dp[i][j] [i] dp i j dp[ni][nj] %= mod dp[ni][nj] [ni] dp ni nj mod dp[ni][nj] += 2 * dp[i][j] dp[ni][nj] [ni] dp ni nj 2 * dp[i][j] 2 dp[i][j] [i] dp i j dp[ni][1] += dp[i][j] dp[ni][1] [ni] dp ni 1 dp[i][j] [i] dp i j dp[ni][nj] %= mod dp[ni][nj] [ni] dp ni nj mod ans = dp[keta][0] + dp[keta][1] ans dp[keta][0] + dp[keta][1] dp[keta][0] [keta] dp keta 0 dp[keta][1] [keta] dp keta 1 ans %= mod ans mod print(ans) print ans L = input() input() L ni = i + 1 i + 1 ni dp = [[0] * 2 for _ in range(keta + 2)] [[0] * 2 for _ in range(keta + 2)] dp nd = int(L[i]) int(L[i]) nd mod = 10 ** 9 + 7 10 ** 9 + 7 mod nj = j j nj ans = dp[keta][0] + dp[keta][1] dp[keta][0] + dp[keta][1] ans keta = len(L) len(L) keta ans %= mod mod ans
# 条件は a+b = a^bよりa&b=0→各ビットごとに(1,0),(0,1),(0,0)の組み合わせのみ
# 上の方から決めていく桁DPになりそう？
# 組み合わせがどれでも良ければ上の3つ、和が0なら1通り、和が1なら上記の2パタ。
# Lは2進数表記
L = input()
keta = len(L)
mod = 10 ** 9 + 7
# dp[桁数][smaller]
dp = [[0] * 2 for _ in range(keta + 2)]
dp[0][0] = 1
for i in range(keta):
    nd = int(L[i])
    for j in range(2):
        ni = i + 1
        nj = j
        if j == 1:
            dp[ni][nj] += 3 * dp[i][j]
            dp[ni][nj] %= mod
        else:
            if nd == 0:
                dp[ni][nj] += dp[i][j]
                dp[ni][nj] %= mod
            else:  # nd==1
                dp[ni][nj] += 2 * dp[i][j]  # (1,0), (0,1)
                dp[ni][1] += dp[i][j]  # (0,0)
                dp[ni][nj] %= mod
ans = dp[keta][0] + dp[keta][1]
ans %= mod
print(ans)
