def power(a, p, mod):
  res = 1
  pwr = a
  while p > 0:
    if p & 1:
      res = res * pwr % mod
    pwr = pwr * pwr % mod
    p >>= 1
  return res

mod = 10**9 + 7

l = [int(bit) for bit in input()]
bl = len(l)
inv3 = power(3, mod-2, mod)
pow2 = 1
pow3 = power(3, bl-1, mod)
count = 0

for i in range(bl-1):
  if l[i]:
    count = (count + pow2 * pow3) % mod
    pow2 = pow2 * 2 % mod
  pow3 = pow3 * inv3 % mod
if l[-1]:
  count = (count + pow2 * 3) % mod
else:
  count = (count + pow2) % mod

print(count) def power(a, p, mod):
  res = 1
  pwr = a
  while p > 0:
    if p & 1:
      res = res * pwr % mod
    pwr = pwr * pwr % mod
    p >>= 1
  return res power res = 1 res 1 pwr = a pwr a while p > 0:
    if p & 1:
      res = res * pwr % mod
    pwr = pwr * pwr % mod
    p >>= 1
   p > 0 p 0 if p & 1:
      res = res * pwr % mod
     p & 1 p 1 res = res * pwr % mod res res * pwr % mod res * pwr res pwr mod pwr = pwr * pwr % mod pwr pwr * pwr % mod pwr * pwr pwr pwr mod p >>= 1 p 1 return res res a a p p mod mod mod = 10**9 + 7 mod 10**9 + 7 10**9 10 9 7 int(bit) for bit in input() for bit in input() bit input() input for bit in input() int(bit) int bit l = [int(bit) for bit in input()] l [int(bit) for bit in input()] bl = len(l) bl len(l) len l inv3 = power(3, mod-2, mod) inv3 power(3, mod-2, mod) power 3 mod-2 mod 2 mod pow2 = 1 pow2 1 pow3 = power(3, bl-1, mod) pow3 power(3, bl-1, mod) power 3 bl-1 bl 1 mod count = 0 count 0 for i in range(bl-1):
  if l[i]:
    count = (count + pow2 * pow3) % mod
    pow2 = pow2 * 2 % mod
  pow3 = pow3 * inv3 % mod i range(bl-1) range bl-1 bl 1 if l[i]:
    count = (count + pow2 * pow3) % mod
    pow2 = pow2 * 2 % mod
   l[i] l i count = (count + pow2 * pow3) % mod count (count + pow2 * pow3) % mod count + pow2 * pow3 count pow2 * pow3 pow2 pow3 mod pow2 = pow2 * 2 % mod pow2 pow2 * 2 % mod pow2 * 2 pow2 2 mod pow3 = pow3 * inv3 % mod pow3 pow3 * inv3 % mod pow3 * inv3 pow3 inv3 mod if l[-1]:
  count = (count + pow2 * 3) % mod
else:
  count = (count + pow2) % mod l[-1] l -1 count = (count + pow2 * 3) % mod count (count + pow2 * 3) % mod count + pow2 * 3 count pow2 * 3 pow2 3 mod count = (count + pow2) % mod count (count + pow2) % mod count + pow2 count pow2 mod print(count) print count pow2 = 1 1 pow2 count = (count + pow2 * 3) % mod (count + pow2 * 3) % mod count count = (count + pow2) % mod (count + pow2) % mod count mod = 10**9 + 7 10**9 + 7 mod pow3 = pow3 * inv3 % mod pow3 * inv3 % mod pow3 bl = len(l) len(l) bl pow3 = power(3, bl-1, mod) power(3, bl-1, mod) pow3 count = (count + pow2 * pow3) % mod (count + pow2 * pow3) % mod count l = [int(bit) for bit in input()] [int(bit) for bit in input()] l def power(a, p, mod):
  res = 1
  pwr = a
  while p > 0:
    if p & 1:
      res = res * pwr % mod
    pwr = pwr * pwr % mod
    p >>= 1
  return res def power(a, p, mod):
  res = 1
  pwr = a
  while p > 0:
    if p & 1:
      res = res * pwr % mod
    pwr = pwr * pwr % mod
    p >>= 1
  return res power inv3 = power(3, mod-2, mod) power(3, mod-2, mod) inv3 count = 0 0 count pow2 = pow2 * 2 % mod pow2 * 2 % mod pow2
def power(a, p, mod):
  res = 1
  pwr = a
  while p > 0:
    if p & 1:
      res = res * pwr % mod
    pwr = pwr * pwr % mod
    p >>= 1
  return res

mod = 10**9 + 7

l = [int(bit) for bit in input()]
bl = len(l)
inv3 = power(3, mod-2, mod)
pow2 = 1
pow3 = power(3, bl-1, mod)
count = 0

for i in range(bl-1):
  if l[i]:
    count = (count + pow2 * pow3) % mod
    pow2 = pow2 * 2 % mod
  pow3 = pow3 * inv3 % mod
if l[-1]:
  count = (count + pow2 * 3) % mod
else:
  count = (count + pow2) % mod

print(count)