l = input()
n = len(l)
mod = pow(10, 9)+7

dp = [0]*n
if l[n-1] == "1":
  dp[0] = 3
else:
  dp[0] = 1
key = 3
for i in range(1, n):
  if l[n-1-i] == "0":
    dp[i] = dp[i-1]
  else:
    dp[i] = (dp[i-1]*2+key)%mod
  key *= 3
  key %= mod
  
print(dp[n-1]) l = input() l input() input n = len(l) n len(l) len l mod = pow(10, 9)+7 mod pow(10, 9)+7 pow(10, 9) pow 10 9 7 dp = [0]*n dp [0]*n [0] 0 n if l[n-1] == "1":
  dp[0] = 3
else:
  dp[0] = 1 l[n-1] == "1" l[n-1] l n-1 n 1 "1" dp[0] = 3 dp[0] dp 0 3 dp[0] = 1 dp[0] dp 0 1 key = 3 key 3 for i in range(1, n):
  if l[n-1-i] == "0":
    dp[i] = dp[i-1]
  else:
    dp[i] = (dp[i-1]*2+key)%mod
  key *= 3
  key %= mod
   i range(1, n) range 1 n if l[n-1-i] == "0":
    dp[i] = dp[i-1]
  else:
    dp[i] = (dp[i-1]*2+key)%mod
   l[n-1-i] == "0" l[n-1-i] l n-1-i n-1 n 1 i "0" dp[i] = dp[i-1] dp[i] dp i dp[i-1] dp i-1 i 1 dp[i] = (dp[i-1]*2+key)%mod dp[i] dp i (dp[i-1]*2+key)%mod dp[i-1]*2+key dp[i-1]*2 dp[i-1] dp i-1 i 1 2 key mod key *= 3 key 3 key %= mod key mod print(dp[n-1]) print dp[n-1] dp n-1 n 1 mod = pow(10, 9)+7 pow(10, 9)+7 mod key %= mod mod key n = len(l) len(l) n key *= 3 3 key l = input() input() l dp = [0]*n [0]*n dp key = 3 3 key
l = input()
n = len(l)
mod = pow(10, 9)+7

dp = [0]*n
if l[n-1] == "1":
  dp[0] = 3
else:
  dp[0] = 1
key = 3
for i in range(1, n):
  if l[n-1-i] == "0":
    dp[i] = dp[i-1]
  else:
    dp[i] = (dp[i-1]*2+key)%mod
  key *= 3
  key %= mod
  
print(dp[n-1])