fun main(args: Array<String>) {
    val (n, m) = readIntList()
    var a = Array(n) { "x" }

    repeat(m) {
        val (s, c) = readStringList()
        if (a[s.toInt() - 1] != "x" && a[s.toInt() - 1] != c) {
            println(-1)
            return
        }
        if (s.toInt() > n) {
            println(-1)
            return
        }
        a[s.toInt() - 1] = c
    }

    if (n > 1 && a[0] == "0") {
        println(-1)
        return
    }

    for (i in 0 until n) {
        if (a[i] == "x") print(1)
        else print(a[i])
    }
    println()
}

// Tools
fun readString() = readLine()!!
fun readInt() = readLine()!!.toInt()
fun readLong() = readLine()!!.toLong()
fun readStringList() = readLine()!!.split(" ")
fun readIntList() = readLine()!!.split(" ").map(String::toInt)
fun readLongList() = readLine()!!.split(" ").map(String::toLong)