MOD = 10 ** 9 + 7
L = input()
N = len(L)
p3 = [1] * N
for i in range(1, N):
    p3[i] = p3[i - 1] * 3 % MOD
p2 = 1
total = 0
for i in range(N):
    if L[i] == "1":
        total = (total + p2 * p3[N - i - 1]) % MOD
        p2 = p2 * 2 % MOD
print((total + p2 * p3[N - i - 1]) % MOD) MOD = 10 ** 9 + 7 MOD 10 ** 9 + 7 10 ** 9 10 9 7 L = input() L input() input N = len(L) N len(L) len L p3 = [1] * N p3 [1] * N [1] 1 N for i in range(1, N):
    p3[i] = p3[i - 1] * 3 % MOD i range(1, N) range 1 N p3[i] = p3[i - 1] * 3 % MOD p3[i] p3 i p3[i - 1] * 3 % MOD p3[i - 1] * 3 p3[i - 1] p3 i - 1 i 1 3 MOD p2 = 1 p2 1 total = 0 total 0 for i in range(N):
    if L[i] == "1":
        total = (total + p2 * p3[N - i - 1]) % MOD
        p2 = p2 * 2 % MOD i range(N) range N if L[i] == "1":
        total = (total + p2 * p3[N - i - 1]) % MOD
        p2 = p2 * 2 % MOD L[i] == "1" L[i] L i "1" total = (total + p2 * p3[N - i - 1]) % MOD total (total + p2 * p3[N - i - 1]) % MOD total + p2 * p3[N - i - 1] total p2 * p3[N - i - 1] p2 p3[N - i - 1] p3 N - i - 1 N - i N i 1 MOD p2 = p2 * 2 % MOD p2 p2 * 2 % MOD p2 * 2 p2 2 MOD print((total + p2 * p3[N - i - 1]) % MOD) print (total + p2 * p3[N - i - 1]) % MOD total + p2 * p3[N - i - 1] total p2 * p3[N - i - 1] p2 p3[N - i - 1] p3 N - i - 1 N - i N i 1 MOD MOD = 10 ** 9 + 7 10 ** 9 + 7 MOD p2 = p2 * 2 % MOD p2 * 2 % MOD p2 total = 0 0 total L = input() input() L total = (total + p2 * p3[N - i - 1]) % MOD (total + p2 * p3[N - i - 1]) % MOD total N = len(L) len(L) N p2 = 1 1 p2 p3 = [1] * N [1] * N p3
MOD = 10 ** 9 + 7
L = input()
N = len(L)
p3 = [1] * N
for i in range(1, N):
    p3[i] = p3[i - 1] * 3 % MOD
p2 = 1
total = 0
for i in range(N):
    if L[i] == "1":
        total = (total + p2 * p3[N - i - 1]) % MOD
        p2 = p2 * 2 % MOD
print((total + p2 * p3[N - i - 1]) % MOD)