import           Control.Monad
import           Data.Array.IO
import           Data.Bits
import qualified Data.ByteString.Char8       as BS
import           Data.Char
import           Data.Maybe
import qualified Data.Vector.Unboxed         as V
import qualified Data.Vector.Unboxed.Mutable as VM

readInt = fst . fromJust . BS.readInt
readIntList = map readInt . BS.words
getInt = readInt <$> BS.getLine
getIntList = readIntList <$> BS.getLine

main = do
  [n, m] <- getIntList
  rs <- replicateM m getIntList

  ds <- VM.new n
  VM.set ds (-1::Int)

  forM_ rs $ \[s, c] -> do
    d <- VM.read ds (s-1)
    let c' = if (d >= 0 && d /= c) || (s == 1 && c == 0) then 10 else c
    VM.write ds (s-1) c'

  d1 <- VM.read ds 0
  when (d1 < 0) $ VM.write ds 0 10

  ds' <- V.freeze ds

  let xs = V.map (\i -> i <= 9) ds'

  if V.and xs
    then do forM_ [0..(n-1)] $ \i -> putStr . show $ max 0 (ds' V.! i)
            putStrLn ""
    else print (-1)