import java.util.Scanner;

fun main (args : Array<String>) {
  val input = Scanner(System.`in`)
  
  while (input.hasNext()) {
    val N = input.nextInt()
    val M = input.nextInt()
    val num = CharArray(N) {'.'}
    var isExist = true
    
    for (i in 1..M) {
      val s = input.nextInt()
      val c = input.nextInt()
      
      if (num[s - 1] == '.') {
        num[s - 1] = (c + '0'.toInt()).toChar()
      } else if (num[s - 1] != (c + '0'.toInt()).toChar()){
        isExist = false
      }
    }
    
    for (i in num.indices) {
      if (num[i] == '.') {
        if (i == 0 && num.size > 1) {
          num[i] = '1'
        } else {
          num[i] = '0'
        }
      }
    }
    
    if (num.size > 1 && num[0] == '0') {
      isExist = false
    }
    
    if (isExist) {
      println(num)
    } else {
      println(-1)
    }
  }
}