fun main(args: Array<String>) {
    val (n, m) = readLine()!!.split(" ").map(String::toInt)
    var s = "0".repeat(n).toCharArray()

    repeat(m) {
        val (si, ci) = readLine()!!.split(" ").map(String::toInt)
        val c = ci.toString()[0]
        if (!(s[si - 1] == c || s[si - 1] == '0')) {
            println(-1)
            return
        }
        s[si - 1] = c
    }

    if (s[n - 1] == '0') {
        println(-1)
        return
    }
    println(String(s))
}



