fun main(args : Array<String>) {
    val (n, m) = readLine()!!.split(" ").map { it.toInt() }
    val num = IntArray(n) { -1 }

    var failed = false
    repeat(m) {
        val (d, i) = readLine()!!.split(" ").map { it.toInt() }

        if (failed) return@repeat

        if (num[d-1] == -1) {
            num[d-1] = i
        } else if (num[d-1] != i) {
            failed = true
        }
    }

    if (failed || num[0] == 0) {
        println("-1")
        return
    }

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

    num.forEachIndexed { index, i ->
        if (i == -1) {
            num[index] = 0
        }
    }

    println(num.joinToString(separator = ""))
}