L = input()
l = len(L)
mod = 10**9 + 7
ans = 1  # (0,0)

d = dict()


def modpow(x, n, mod):
    if x not in d:
        d[x] = [1]
    l = len(d[x])
    ret = d[x][-1]
    for i in range(l, n+1):
        ret *= x
        ret %= mod
        d[x].append(ret)
    return(d[x][n])


ans = modpow(3, l, mod)

r = 0
count = 0

for i in range(l):
    if L[i] == '0':
        r = modpow(3, l-i-1, mod) * modpow(2, count, mod) * 2
        ans -= r
        ans %= mod
    else:
        count += 1
print(ans) L = input() L input() input l = len(L) l len(L) len L mod = 10**9 + 7 mod 10**9 + 7 10**9 10 9 7 ans = 1 ans 1 d = dict() d dict() dict def modpow(x, n, mod):
    if x not in d:
        d[x] = [1]
    l = len(d[x])
    ret = d[x][-1]
    for i in range(l, n+1):
        ret *= x
        ret %= mod
        d[x].append(ret)
    return(d[x][n]) modpow if x not in d:
        d[x] = [1]
     x not in d x d d[x] = [1] d[x] d x [1] 1 l = len(d[x]) l len(d[x]) len d[x] d x ret = d[x][-1] ret d[x][-1] [x] d x -1 for i in range(l, n+1):
        ret *= x
        ret %= mod
        d[x].append(ret)
     i range(l, n+1) range l n+1 n 1 ret *= x ret x ret %= mod ret mod d[x].append(ret) [x].append [x] d x append ret return(d[x][n]) d[x][n] [x] d x n x x n n mod mod ans = modpow(3, l, mod) ans modpow(3, l, mod) modpow 3 l mod r = 0 r 0 count = 0 count 0 for i in range(l):
    if L[i] == '0':
        r = modpow(3, l-i-1, mod) * modpow(2, count, mod) * 2
        ans -= r
        ans %= mod
    else:
        count += 1 i range(l) range l if L[i] == '0':
        r = modpow(3, l-i-1, mod) * modpow(2, count, mod) * 2
        ans -= r
        ans %= mod
    else:
        count += 1 L[i] == '0' L[i] L i '0' r = modpow(3, l-i-1, mod) * modpow(2, count, mod) * 2 r modpow(3, l-i-1, mod) * modpow(2, count, mod) * 2 modpow(3, l-i-1, mod) * modpow(2, count, mod) modpow(3, l-i-1, mod) modpow 3 l-i-1 l-i l i 1 mod modpow(2, count, mod) modpow 2 count mod 2 ans -= r ans r ans %= mod ans mod count += 1 count 1 print(ans) print ans def modpow(x, n, mod):
    if x not in d:
        d[x] = [1]
    l = len(d[x])
    ret = d[x][-1]
    for i in range(l, n+1):
        ret *= x
        ret %= mod
        d[x].append(ret)
    return(d[x][n]) def modpow(x, n, mod):
    if x not in d:
        d[x] = [1]
    l = len(d[x])
    ret = d[x][-1]
    for i in range(l, n+1):
        ret *= x
        ret %= mod
        d[x].append(ret)
    return(d[x][n]) modpow count = 0 0 count ans = modpow(3, l, mod) modpow(3, l, mod) ans ans %= mod mod ans d = dict() dict() d L = input() input() L count += 1 1 count r = modpow(3, l-i-1, mod) * modpow(2, count, mod) * 2 modpow(3, l-i-1, mod) * modpow(2, count, mod) * 2 r l = len(L) len(L) l r = 0 0 r ans -= r r ans mod = 10**9 + 7 10**9 + 7 mod ans = 1 1 ans
L = input()
l = len(L)
mod = 10**9 + 7
ans = 1  # (0,0)

d = dict()


def modpow(x, n, mod):
    if x not in d:
        d[x] = [1]
    l = len(d[x])
    ret = d[x][-1]
    for i in range(l, n+1):
        ret *= x
        ret %= mod
        d[x].append(ret)
    return(d[x][n])


ans = modpow(3, l, mod)

r = 0
count = 0

for i in range(l):
    if L[i] == '0':
        r = modpow(3, l-i-1, mod) * modpow(2, count, mod) * 2
        ans -= r
        ans %= mod
    else:
        count += 1
print(ans)
