fun main(args: Array<String>){
    val (n, m) = readLine()!!.split(" ").map { it.toInt() }
    val s = IntArray(m)
    val c = IntArray(m)
    for(i in 0 until m){
        readLine()!!.split(" ").map { it.toInt() }.let {
            s[i] = it[0] - 1
            c[i] = it[1]
        }
    }
    for(i in pow(10, n - 1) until pow(10, n)){
        var f = true
        for(j in 0 until m){
            f = f && i.toString()[s[j]].toString().toInt() == c[j]
        }
        if(f){
            println(i)
            return
        }
    }
    println(-1)
}

fun pow(a: Int, b: Int): Int{
    return Math.pow(a.toDouble(), b.toDouble()).toInt()
}