import java.util.*

fun main(args: Array<String>) {
   val sc = Scanner(System.`in`)
   val n = sc.nextInt()
   val m = sc.nextInt()
   val nums = IntArray(n)

   for(i in 0 until n){
      nums[i] = -1
   }

   for(i in 0 until m) {
      val s = sc.nextInt() -1
      val c = sc.nextInt()

      if(nums[s] != -1 && nums[s] != c){
         println(-1)
         return
      }

      if(s == 0 && c == 0 && n  != 1) {
         println(-1)
         return
      }

      nums[s] = c
   }

    if(nums[0] == -1){
       nums[0] = 1
    }

   for(i in 0 until n){
      if(nums[i] == -1) nums[i] = 0
   }

   var ans: String = ""
   for(i in 0 until n){
      ans += nums[i].toString()
   }

   println(ans)

}


