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

    repeat(m) {
        val (s, c) = readIntList()
        if (s > n || a[s - 1] != c.toChar()) {
            println(-1)
            return
        }
        a[s - 1] = c.toChar()
    }

    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)