fun main(args:Array<String>) {
    val (n,m) = readLine()!!.split(" ").map { it.toInt() }
    val num = mutableListOf<Int?>()
    num.addAll((1..n).map { null })
    val query = (1..m).map { readLine()!!.split(" ").map { it.toInt() }.let { listOf(it[0]-1,it[1]) } }
    for(tmp in query) {
        val idx = tmp[0]
        if(num[idx] == null) {
            num[idx] = tmp[1]
        } else {
            if(num[idx]!! != tmp[1]) {
                println(-1)
                return
            }
        }
    }
    for(i in num.indices) {
        if(num[i] == null) {
            if(num.size > 1 && i == 0) {
                num[i] = 1
            } else {
                num[i] = 0
            }
        }
    }
    if(num.size > 1 && num[0] == 0) {
        println(-1)
        return
    }
    println(num.joinToString(""))

}
