L = input()

result = 1
t = 1
for c in L[::-1]:
    if c == '1':
        result = result * 2 + t
        result %= 1000000007
    t *= 3
    t %= 1000000007
print(result) L = input() L input() input result = 1 result 1 t = 1 t 1 for c in L[::-1]:
    if c == '1':
        result = result * 2 + t
        result %= 1000000007
    t *= 3
    t %= 1000000007 c L[::-1] L ::-1 -1 if c == '1':
        result = result * 2 + t
        result %= 1000000007
     c == '1' c '1' result = result * 2 + t result result * 2 + t result * 2 result 2 t result %= 1000000007 result 1000000007 t *= 3 t 3 t %= 1000000007 t 1000000007 print(result) print result result = 1 1 result result %= 1000000007 1000000007 result result = result * 2 + t result * 2 + t result t = 1 1 t t *= 3 3 t t %= 1000000007 1000000007 t L = input() input() L
L = input()

result = 1
t = 1
for c in L[::-1]:
    if c == '1':
        result = result * 2 + t
        result %= 1000000007
    t *= 3
    t %= 1000000007
print(result)