data Tree = Empty { contents :: (Int,Int)
                      ,maxCont :: (Int,Int)}| 
               Node { contents :: (Int,Int)
                     ,maxCont :: (Int,Int)
                     ,leftTree :: Tree
                     ,rightTree :: Tree}

empty :: Tree
empty = Empty (-1,-1) (-1,-1)

comp :: (Int,Int) -> (Int,Int) -> (Int,Int)
comp (a,b) (x,y)
  | b < y  = (x,y)
  | otherwise = (a,b)

update :: (Int,Int) -> Tree -> Tree
update (x,y) (Empty _ _) = Node (x,y) (x,y) empty empty
update (x,y) (Node (a,b) (c,d) left right)
  | x == a = Node
                (a,b+y)
                ((maxCont left) `comp` (a,b+y) `comp` (maxCont right))
                left
                right
  | x < a  = Node
                (a,b)
                ((maxCont left') `comp` (a,b) `comp` (maxCont right))
                left'
                right
  | x > a  = Node
                (a,b)
                ((maxCont left) `comp` (a,b) `comp` (maxCont right'))
                left
                right'
  where right' = update (x,y) right
        left' = update (x,y) left

format :: (Int,Int) -> String
format (a,b) = (show a) ++ " " ++ (show b)

main :: IO ()
main = do
  nq <- getLine
  let [n,q] = map (read :: String -> Int) $ words nq
      counter = q
      initTree = empty
  loopq counter initTree

loopq counter tree = do
  if counter <= 0
    then return ()
    else do
      av <- getLine
      let [a,v] = map (read :: String -> Int) $ words av
          tree' = update (a,v) tree
          ans = maxCont tree'
      putStrLn $ format ans
      loopq (counter - 1) tree'