l = input()

ans = 1
mod = 10**9+7
strict = 1
# st_m = 0
easy = 0
# ea_m = 0
for i in range(len(l)):
    if l[i] == "1":
        easy *= 3
        easy %= mod

        easy = easy + strict
        # ea_m += st_m
        strict *= 2
        # st_m *= 2
        # st_m += strict//mod
        strict %= mod

    else:
        easy *= 3
        # ea_m *= 3
        # ea_m += easy//mod
        easy %= mod
    # print(easy,strict)

# print(easy,strict)

print((easy+strict)%mod) l = input() l input() input ans = 1 ans 1 mod = 10**9+7 mod 10**9+7 10**9 10 9 7 strict = 1 strict 1 easy = 0 easy 0 for i in range(len(l)):
    if l[i] == "1":
        easy *= 3
        easy %= mod

        easy = easy + strict
        # ea_m += st_m
        strict *= 2
        # st_m *= 2
        # st_m += strict//mod
        strict %= mod

    else:
        easy *= 3
        # ea_m *= 3
        # ea_m += easy//mod
        easy %= mod
    # print(easy,strict)

# print(easy,strict) i range(len(l)) range len(l) len l if l[i] == "1":
        easy *= 3
        easy %= mod

        easy = easy + strict
        # ea_m += st_m
        strict *= 2
        # st_m *= 2
        # st_m += strict//mod
        strict %= mod

    else:
        easy *= 3
        # ea_m *= 3
        # ea_m += easy//mod
        easy %= mod
    # print(easy,strict)

# print(easy,strict) l[i] == "1" l[i] l i "1" easy *= 3 easy 3 easy %= mod easy mod easy = easy + strict easy easy + strict easy strict strict *= 2 strict 2 strict %= mod strict mod easy *= 3 easy 3 easy %= mod easy mod print((easy+strict)%mod) print (easy+strict)%mod easy+strict easy strict mod l = input() input() l ans = 1 1 ans strict *= 2 2 strict easy %= mod mod easy strict = 1 1 strict easy = easy + strict easy + strict easy easy *= 3 3 easy mod = 10**9+7 10**9+7 mod strict %= mod mod strict easy %= mod mod easy easy = 0 0 easy easy *= 3 3 easy
l = input()

ans = 1
mod = 10**9+7
strict = 1
# st_m = 0
easy = 0
# ea_m = 0
for i in range(len(l)):
    if l[i] == "1":
        easy *= 3
        easy %= mod

        easy = easy + strict
        # ea_m += st_m
        strict *= 2
        # st_m *= 2
        # st_m += strict//mod
        strict %= mod

    else:
        easy *= 3
        # ea_m *= 3
        # ea_m += easy//mod
        easy %= mod
    # print(easy,strict)

# print(easy,strict)

print((easy+strict)%mod)