MOD = 10 ** 9 + 7
L = input()
N = len(L)
total = 0
one_count = 0
pow2, pow3 = [1], [1]
p2, p3 = 1, 1
for i in range(N):
    p2 = p2 * 2 % MOD
    p3 = p3 * 3 % MOD
    pow2.append(p2)
    pow3.append(p3)
for i in range(N):
    if L[i] == "1":
        total = (total + pow2[one_count] * pow3[N - i - 1]) % MOD
        one_count += 1
print((total + pow2[one_count] * pow3[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 total = 0 total 0 one_count = 0 one_count 0 pow2, pow3 = [1], [1] pow2 [1] 1 pow3 [1] 1 p2, p3 = 1, 1 p2 1 p3 1 for i in range(N):
    p2 = p2 * 2 % MOD
    p3 = p3 * 3 % MOD
    pow2.append(p2)
    pow3.append(p3) i range(N) range N p2 = p2 * 2 % MOD p2 p2 * 2 % MOD p2 * 2 p2 2 MOD p3 = p3 * 3 % MOD p3 p3 * 3 % MOD p3 * 3 p3 3 MOD pow2.append(p2) pow2.append pow2 append p2 pow3.append(p3) pow3.append pow3 append p3 for i in range(N):
    if L[i] == "1":
        total = (total + pow2[one_count] * pow3[N - i - 1]) % MOD
        one_count += 1 i range(N) range N if L[i] == "1":
        total = (total + pow2[one_count] * pow3[N - i - 1]) % MOD
        one_count += 1 L[i] == "1" L[i] L i "1" total = (total + pow2[one_count] * pow3[N - i - 1]) % MOD total (total + pow2[one_count] * pow3[N - i - 1]) % MOD total + pow2[one_count] * pow3[N - i - 1] total pow2[one_count] * pow3[N - i - 1] pow2[one_count] pow2 one_count pow3[N - i - 1] pow3 N - i - 1 N - i N i 1 MOD one_count += 1 one_count 1 print((total + pow2[one_count] * pow3[N - i - 1]) % MOD) print (total + pow2[one_count] * pow3[N - i - 1]) % MOD total + pow2[one_count] * pow3[N - i - 1] total pow2[one_count] * pow3[N - i - 1] pow2[one_count] pow2 one_count pow3[N - i - 1] pow3 N - i - 1 N - i N i 1 MOD L = input() input() L p3 = p3 * 3 % MOD p3 * 3 % MOD p3 total = 0 0 total pow3 = [1], [1] [1] pow3 p2 = p2 * 2 % MOD p2 * 2 % MOD p2 one_count += 1 1 one_count p3 = 1, 1 1 p3 one_count = 0 0 one_count pow2, pow3 = [1], [1] [1] pow2 p2, p3 = 1, 1 1 p2 total = (total + pow2[one_count] * pow3[N - i - 1]) % MOD (total + pow2[one_count] * pow3[N - i - 1]) % MOD total MOD = 10 ** 9 + 7 10 ** 9 + 7 MOD N = len(L) len(L) N
MOD = 10 ** 9 + 7
L = input()
N = len(L)
total = 0
one_count = 0
pow2, pow3 = [1], [1]
p2, p3 = 1, 1
for i in range(N):
    p2 = p2 * 2 % MOD
    p3 = p3 * 3 % MOD
    pow2.append(p2)
    pow3.append(p3)
for i in range(N):
    if L[i] == "1":
        total = (total + pow2[one_count] * pow3[N - i - 1]) % MOD
        one_count += 1
print((total + pow2[one_count] * pow3[N - i - 1]) % MOD)
