import Data.List
import Debug.Trace
import qualified Data.IntMap as M

k = 1000000007
maxN = 100001

toMap = M.fromList . zip [0..]

fact i = facts M.! i
  where facts = toMap $ reverse $ foldl' (\z i -> head z * i `mod` k : z) [1] [1..maxN]

nCr n r = fact n * invfact r `mod` k * invfact (n-r) `mod` k
  where invfact i = invfacts M.! i
          where inv = foldl' step (M.fromList [(0,0),(1,1)]) [2..maxN]
                  where step z i = M.insert i (k - ((k `div` i) * (z M.! (k `mod` i)) `mod` k)) z
                invfacts = toMap $ reverse $ foldl' (\z i -> head z * inv M.! i `mod` k : z) [1] [1..maxN]


solve :: [[Int]] -> IO Integer
solve ((n:_):xs:_) = step 1
  where
    (a:b:_) = elemIndices (head (xs \\ nub xs)) xs
    m = a + n - b
    step i
      | i > n+1 = return 0
      | i-1 > m = print (nCr (n+1) i) >> step (i+1)
      | otherwise = print (nCr (n+1) i - nCr m (i-1)) >> step (i+1)

main = getContents >>= solve.map (map read . words).lines
