L = input()
MOD = 10**9+7

num_ab = [1]
for i in range(1, len(L)+1):
    num_ab.append((num_ab[-1] * 3) % MOD)

ans, m = 0, 1
while True:
    if '0' not in L:
        ans = (ans + (m * num_ab[len(L)]) % MOD) % MOD
        print(ans)
        exit()
    elif '1' not in L[1:]:
        ans = (ans + ((m * num_ab[len(L) - 1]) % MOD + (2 * m) % MOD) % MOD) % MOD
        print(ans)
        exit()
    else:
        ans = (ans + (m * num_ab[len(L) - 1]) % MOD) % MOD
        L = L[L[1:].index('1') + 1:]
        m = (2 * m) % MOD L = input() L input() input MOD = 10**9+7 MOD 10**9+7 10**9 10 9 7 num_ab = [1] num_ab [1] 1 for i in range(1, len(L)+1):
    num_ab.append((num_ab[-1] * 3) % MOD) i range(1, len(L)+1) range 1 len(L)+1 len(L) len L 1 num_ab.append((num_ab[-1] * 3) % MOD) num_ab.append num_ab append (num_ab[-1] * 3) % MOD num_ab[-1] * 3 num_ab[-1] num_ab -1 3 MOD ans, m = 0, 1 ans 0 m 1 while True:
    if '0' not in L:
        ans = (ans + (m * num_ab[len(L)]) % MOD) % MOD
        print(ans)
        exit()
    elif '1' not in L[1:]:
        ans = (ans + ((m * num_ab[len(L) - 1]) % MOD + (2 * m) % MOD) % MOD) % MOD
        print(ans)
        exit()
    else:
        ans = (ans + (m * num_ab[len(L) - 1]) % MOD) % MOD
        L = L[L[1:].index('1') + 1:]
        m = (2 * m) % MOD True if '0' not in L:
        ans = (ans + (m * num_ab[len(L)]) % MOD) % MOD
        print(ans)
        exit()
    elif '1' not in L[1:]:
        ans = (ans + ((m * num_ab[len(L) - 1]) % MOD + (2 * m) % MOD) % MOD) % MOD
        print(ans)
        exit()
    else:
        ans = (ans + (m * num_ab[len(L) - 1]) % MOD) % MOD
        L = L[L[1:].index('1') + 1:]
        m = (2 * m) % MOD '0' not in L '0' L ans = (ans + (m * num_ab[len(L)]) % MOD) % MOD ans (ans + (m * num_ab[len(L)]) % MOD) % MOD ans + (m * num_ab[len(L)]) % MOD ans (m * num_ab[len(L)]) % MOD m * num_ab[len(L)] m num_ab[len(L)] num_ab len(L) len L MOD MOD print(ans) print ans exit() exit elif '1' not in L[1:]:
        ans = (ans + ((m * num_ab[len(L) - 1]) % MOD + (2 * m) % MOD) % MOD) % MOD
        print(ans)
        exit()
     '1' not in L[1:] '1' L[1:] L 1: 1 ans = (ans + ((m * num_ab[len(L) - 1]) % MOD + (2 * m) % MOD) % MOD) % MOD ans (ans + ((m * num_ab[len(L) - 1]) % MOD + (2 * m) % MOD) % MOD) % MOD ans + ((m * num_ab[len(L) - 1]) % MOD + (2 * m) % MOD) % MOD ans ((m * num_ab[len(L) - 1]) % MOD + (2 * m) % MOD) % MOD (m * num_ab[len(L) - 1]) % MOD + (2 * m) % MOD (m * num_ab[len(L) - 1]) % MOD m * num_ab[len(L) - 1] m num_ab[len(L) - 1] num_ab len(L) - 1 len(L) len L 1 MOD (2 * m) % MOD 2 * m 2 m MOD MOD MOD print(ans) print ans exit() exit ans = (ans + (m * num_ab[len(L) - 1]) % MOD) % MOD ans (ans + (m * num_ab[len(L) - 1]) % MOD) % MOD ans + (m * num_ab[len(L) - 1]) % MOD ans (m * num_ab[len(L) - 1]) % MOD m * num_ab[len(L) - 1] m num_ab[len(L) - 1] num_ab len(L) - 1 len(L) len L 1 MOD MOD L = L[L[1:].index('1') + 1:] L L[L[1:].index('1') + 1:] L L[1:].index('1') + 1: L[1:].index('1') + 1 L[1:].index('1') [1:].index [1:] L 1: 1 index '1' 1 m = (2 * m) % MOD m (2 * m) % MOD 2 * m 2 m MOD m = 0, 1 1 m ans = (ans + ((m * num_ab[len(L) - 1]) % MOD + (2 * m) % MOD) % MOD) % MOD (ans + ((m * num_ab[len(L) - 1]) % MOD + (2 * m) % MOD) % MOD) % MOD ans ans, m = 0, 1 0 ans L = input() input() L MOD = 10**9+7 10**9+7 MOD L = L[L[1:].index('1') + 1:] L[L[1:].index('1') + 1:] L num_ab = [1] [1] num_ab ans = (ans + (m * num_ab[len(L)]) % MOD) % MOD (ans + (m * num_ab[len(L)]) % MOD) % MOD ans m = (2 * m) % MOD (2 * m) % MOD m ans = (ans + (m * num_ab[len(L) - 1]) % MOD) % MOD (ans + (m * num_ab[len(L) - 1]) % MOD) % MOD ans
L = input()
MOD = 10**9+7

num_ab = [1]
for i in range(1, len(L)+1):
    num_ab.append((num_ab[-1] * 3) % MOD)

ans, m = 0, 1
while True:
    if '0' not in L:
        ans = (ans + (m * num_ab[len(L)]) % MOD) % MOD
        print(ans)
        exit()
    elif '1' not in L[1:]:
        ans = (ans + ((m * num_ab[len(L) - 1]) % MOD + (2 * m) % MOD) % MOD) % MOD
        print(ans)
        exit()
    else:
        ans = (ans + (m * num_ab[len(L) - 1]) % MOD) % MOD
        L = L[L[1:].index('1') + 1:]
        m = (2 * m) % MOD