import Control.Monad
import Data.List
import Data.Maybe
import Data.Ord
import qualified Data.IntSet as S

main = do
  [n,q] <- map read.words<$>getLine
  stxs <- replicateM n $ map read.words<$>getLine
  ds <- replicateM q readLn
  putStr $ solve stxs ds

solve :: [[Int]] -> [Int] -> String
solve stxs ds = unlines $ map show ans
  where
  ans = go S.empty ops ds
  go _ _ [] = []
  go _ [] ds = map (const(-1)) ds
  go con ((t,op):ops) (d:ds)
    | d < t = stop : go con ((t,op):ops) ds
    | otherwise = go (op con) ops (d:ds)
    where stop = fst $ fromMaybe (-1,S.empty) $ S.minView con
  ops = sortOn fst $ concat[[(s-x,S.insert x),(t-x,S.delete x)]|[s,t,x]<-stxs]
  sortOn f =
    map snd . sortBy (comparing fst) . map (\x -> let y = f x in y `seq` (y, x))