L = input()
ll = len(L)
MOD = 10**9 + 7
#[*2 if 1][*1 if 1][*3]

comb = 1
ans = 0
for i, l in enumerate(L):
  if l == '0':
    continue
  ans += comb * pow(3, ll - i - 1, MOD)
  
  comb *= 2
  comb %= MOD

ans += comb
ans %= MOD
print(ans)
 L = input() L input() input ll = len(L) ll len(L) len L MOD = 10**9 + 7 MOD 10**9 + 7 10**9 10 9 7 comb = 1 comb 1 ans = 0 ans 0 for i, l in enumerate(L):
  if l == '0':
    continue
  ans += comb * pow(3, ll - i - 1, MOD)
  
  comb *= 2
  comb %= MOD i l enumerate(L) enumerate L if l == '0':
    continue
   l == '0' l '0' continue ans += comb * pow(3, ll - i - 1, MOD) ans comb * pow(3, ll - i - 1, MOD) comb pow(3, ll - i - 1, MOD) pow 3 ll - i - 1 ll - i ll i 1 MOD comb *= 2 comb 2 comb %= MOD comb MOD ans += comb ans comb ans %= MOD ans MOD print(ans) print ans L = input() input() L ans += comb comb ans comb = 1 1 comb ans += comb * pow(3, ll - i - 1, MOD) comb * pow(3, ll - i - 1, MOD) ans comb *= 2 2 comb ans = 0 0 ans ans %= MOD MOD ans ll = len(L) len(L) ll MOD = 10**9 + 7 10**9 + 7 MOD comb %= MOD MOD comb
L = input()
ll = len(L)
MOD = 10**9 + 7
#[*2 if 1][*1 if 1][*3]

comb = 1
ans = 0
for i, l in enumerate(L):
  if l == '0':
    continue
  ans += comb * pow(3, ll - i - 1, MOD)
  
  comb *= 2
  comb %= MOD

ans += comb
ans %= MOD
print(ans)

