{-# LANGUAGE TupleSections #-} import Control.Monad.State import Data.Char import Data.Coerce import qualified Data.ByteString.Char8 as BSC8 import qualified Data.Vector.Unboxed as VU main :: IO () main = do [n, m] <- map (read :: String -> Int) . words <$> getLine ls <- seqInput n let xs = VU.tail . VU.indexed . VU.unsafeAccumulate (+) (VU.replicate (m + 1) 0) . VU.map (, 1 :: Int) $ ls VU.forM_ xs $ \(a, b) -> putStrLn $ show a ++ " " ++ show b type CParser a = StateT BSC8.ByteString Maybe a runCParser :: CParser a -> BSC8.ByteString -> Maybe (a, BSC8.ByteString) runCParser = runStateT {-# INLINE runCParser #-} int :: CParser Int int = coerce $ BSC8.readInt . BSC8.dropWhile isSpace {-# INLINE int #-} seqInput :: Int -> IO (VU.Vector Int) seqInput n = VU.unfoldrN n (runCParser int) <$> BSC8.getLine {-# INLINE seqInput #-}