import Control.Arrow
import Control.Monad
import Data.List
import qualified Data.ByteString.Char8 as B
import qualified Data.Set as S 
import Data.Function
import Data.Ord

main :: IO ()
main = readLine >>= main'
    where
        main' [n, q] = inputs n q >>= printRes . uncurry solve
        inputs x y = (,) <$> readContents x <*> replicateM y (head <$> readLine)
        printRes = mapM_ print

solve :: [[Int]] -> [Int] -> [Int]
solve stxs ds = check ds S.empty . sortOn fst . edit $ sortBy cmpf stxs
    where
        cmpf lhs rhs = comparing last lhs rhs `mappend` comparing head lhs rhs

        edit ([s0, t0, v0] : y@[s1, t1, v1] : zs)
            | v0 == v1 && t0 == s1 = edit $ [s0, t1, v0] : zs
            | otherwise = (s0 - v0, (True, v0)) : (t0 - v0, (False, v0)) : edit (y : zs)
        edit [[s, t, v]] = [(s - v, (True, v)), (t - v, (False, v))]
        edit _ = []

        check xxs@(d : xs) ss yys@((t, (b, x)) : ys)
            | d < t = res : check xs ss yys
            | otherwise = check xxs us ys
            where
                res = maybe (-1) fst $ S.minView ss
                us 
                    | b = S.insert x ss
                    | otherwise = S.delete x ss
        check xs ss _ = replicate (length xs) res
            where
                res = maybe (-1) fst $ S.minView ss


readLine :: IO [Int]
readLine = unfoldr (fmap (second (maybe B.empty snd . B.uncons)) . B.readInt) <$> B.getLine

readContents :: Int -> IO [[Int]]
readContents = flip replicateM readLine