object Main extends App {
	val Array(n, m) = scala.io.StdIn.readLine.split(" ").map(_.toInt)
	var map = Map[Int, Int]()
	var flag = true

	for(i<-0 until m){
		val Array(s, c) = scala.io.StdIn.readLine.split(" ").map(_.toInt)

		if(map.contains(s)){
			if(map(s) != c) flag = false
		}else{
			map += s->c
		}
	}

	if(!flag) println(-1)
	else {
		val a = new Array[Int](n)

		for(x<-map){
			a(x._1 - 1) = x._2
		}

		if(a(0) == 0 && n != 1) println(-1)
		else println(a.mkString)
	}

}