fun readString() = readLine()!!
fun readInt() = readLine()!!.toInt()
fun readLong() = readLine()!!.toLong()
fun readIntList() = readLine()!!.split(" ").map(String::toInt)
fun readLongList() = readLine()!!.split(" ").map(String::toLong)
fun <T> Array<Array<T>>.print() {
    this.forEach {
        println(it.joinToString(" "))
    }
}

fun main() {
    val (n, m) = readIntList()
    val res = Array(n + 1) { -1 }

    for (i in 0 until m) {
        val (s, c) = readIntList()
        if (res[s] != -1 && res[s] != c) {
            println(-1)
            return
        }
        res[s] = c
    }

    for (i in 1..n) {
        if (res[i] == -1) {
            if (i == 1) {
                res[i] = 1
            } else {
                res[i] = 0
            }
        }
    }

    if (res[1] == 0) {
        println(-1)
    } else {
        println(res.drop(1).joinToString(separator = ""))
    }
}
