import qualified Data.ByteString.Char8 as B import qualified Data.Set as S type Heap = S.Set (Integer,Int) main = do [_,k] <- map read . words <$> getLine qs <- map readIntegers . B.lines <$> B.getContents let hmax = S.empty let hmin = S.empty let (_, _, ans) = foldl (query k) (hmax, hmin, []) (zip qs [0..]) mapM_ print (reverse ans) query :: Int -> (Heap, Heap, [Integer]) -> ([Integer], Int) -> (Heap, Heap, [Integer]) query k (hmax, hmin, acc) ([1,x],i) | S.size hmax < k = (S.insert (x,i) hmax, hmin, acc) | x < xmax = (S.insert (x,i) hmax', S.insert (xmax,j) hmin, acc) | otherwise = (hmax, S.insert (x,i) hmin, acc) where ((xmax,j), hmax') = S.deleteFindMax hmax query k (hmax, hmin, acc) ([2],_) | S.size hmax < k = (hmax, hmin, (-1):acc) | S.null hmin = (hmax', hmin, xmax:acc) | otherwise = (S.insert (xmin,j) hmax', hmin', xmax:acc) where ((xmax,i), hmax') = S.deleteFindMax hmax ((xmin,j), hmin') = S.deleteFindMin hmin readInteger :: B.ByteString -> Integer readInteger = maybe undefined fst . B.readInteger readIntegers :: B.ByteString -> [Integer] readIntegers = map readInteger . B.words