L = input()
l = len(L)
dp = [[0]*2 for _ in range(100002)]
# dp[i][smaller]: i桁目までみる　未満なら1
# dp[i][1] : i桁目までみて、a, bどちらもL未満
# dp[i][0] : i桁目までみて、a+b = L
dp[0][0] = 1
mod = 10**9+7

for i in range(l):
  n = L[i]

  if n == '1':
    dp[i+1][0] += dp[i][0]*2 
    dp[i+1][0] %= mod 

    dp[i+1][1] += dp[i][1]*3 + dp[i][0]
    dp[i+1][1] %= mod 

  else:
    dp[i+1][0] += dp[i][0]
    dp[i+1][0] %= mod 

    dp[i+1][1] += dp[i][1]*3
    dp[i+1][1] %= mod

print((dp[l][0]+dp[l][1])%mod) L = input() L input() input l = len(L) l len(L) len L [0]*2 for _ in range(100002) for _ in range(100002) _ range(100002) range 100002 for _ in range(100002) [0]*2 [0] 0 2 dp = [[0]*2 for _ in range(100002)] dp [[0]*2 for _ in range(100002)] dp[0][0] = 1 dp[0][0] [0] dp 0 0 1 mod = 10**9+7 mod 10**9+7 10**9 10 9 7 for i in range(l):
  n = L[i]

  if n == '1':
    dp[i+1][0] += dp[i][0]*2 
    dp[i+1][0] %= mod 

    dp[i+1][1] += dp[i][1]*3 + dp[i][0]
    dp[i+1][1] %= mod 

  else:
    dp[i+1][0] += dp[i][0]
    dp[i+1][0] %= mod 

    dp[i+1][1] += dp[i][1]*3
    dp[i+1][1] %= mod i range(l) range l n = L[i] n L[i] L i if n == '1':
    dp[i+1][0] += dp[i][0]*2 
    dp[i+1][0] %= mod 

    dp[i+1][1] += dp[i][1]*3 + dp[i][0]
    dp[i+1][1] %= mod 

  else:
    dp[i+1][0] += dp[i][0]
    dp[i+1][0] %= mod 

    dp[i+1][1] += dp[i][1]*3
    dp[i+1][1] %= mod n == '1' n '1' dp[i+1][0] += dp[i][0]*2 dp[i+1][0] [i+1] dp i+1 i 1 0 dp[i][0]*2 dp[i][0] [i] dp i 0 2 dp[i+1][0] %= mod dp[i+1][0] [i+1] dp i+1 i 1 0 mod dp[i+1][1] += dp[i][1]*3 + dp[i][0] dp[i+1][1] [i+1] dp i+1 i 1 1 dp[i][1]*3 + dp[i][0] dp[i][1]*3 dp[i][1] [i] dp i 1 3 dp[i][0] [i] dp i 0 dp[i+1][1] %= mod dp[i+1][1] [i+1] dp i+1 i 1 1 mod dp[i+1][0] += dp[i][0] dp[i+1][0] [i+1] dp i+1 i 1 0 dp[i][0] [i] dp i 0 dp[i+1][0] %= mod dp[i+1][0] [i+1] dp i+1 i 1 0 mod dp[i+1][1] += dp[i][1]*3 dp[i+1][1] [i+1] dp i+1 i 1 1 dp[i][1]*3 dp[i][1] [i] dp i 1 3 dp[i+1][1] %= mod dp[i+1][1] [i+1] dp i+1 i 1 1 mod print((dp[l][0]+dp[l][1])%mod) print (dp[l][0]+dp[l][1])%mod dp[l][0]+dp[l][1] dp[l][0] [l] dp l 0 dp[l][1] [l] dp l 1 mod n = L[i] L[i] n dp = [[0]*2 for _ in range(100002)] [[0]*2 for _ in range(100002)] dp mod = 10**9+7 10**9+7 mod L = input() input() L l = len(L) len(L) l
L = input()
l = len(L)
dp = [[0]*2 for _ in range(100002)]
# dp[i][smaller]: i桁目までみる　未満なら1
# dp[i][1] : i桁目までみて、a, bどちらもL未満
# dp[i][0] : i桁目までみて、a+b = L
dp[0][0] = 1
mod = 10**9+7

for i in range(l):
  n = L[i]

  if n == '1':
    dp[i+1][0] += dp[i][0]*2 
    dp[i+1][0] %= mod 

    dp[i+1][1] += dp[i][1]*3 + dp[i][0]
    dp[i+1][1] %= mod 

  else:
    dp[i+1][0] += dp[i][0]
    dp[i+1][0] %= mod 

    dp[i+1][1] += dp[i][1]*3
    dp[i+1][1] %= mod

print((dp[l][0]+dp[l][1])%mod)