fun main(args: Array<String>) {
    val (n, m) = readLongList()
    val conditionArray = Array(m.toInt()) { readIntegerList() }
    for (i in pow(10, n - 1, Long.MAX_VALUE) until pow(10, n, Long.MAX_VALUE)) {
        if (isOk(i.toString(), conditionArray)) {
            println(i)
            return
        }
    }

    println(-1)
}

fun isOk(i: String, cArray: Array<List<Int>>): Boolean {
    if (i.length > 1 && i[0].toString() == "0") {
        return false
    }
    
    for (c in cArray) {
        if (i[c[0] - 1].toString() != c[1].toString()) {
            return false
        }
    }

    return true
}

fun pow(n: Long, m: Long, MOD: Long): Long {
    var ret = 1L
    var x = n
    var k = m
    while (k > 0) {
        if ((k and 1L) == 1L) {
            ret = (ret * x) % MOD
        }
        x = (x * x) % MOD
        k = k shr 1
    }

    return ret
}

fun readInteger() = readLine()!!.toInt()
fun readLong() = readLine()!!.toLong()
fun readStringList() = readLine()!!.split(" ")
fun readIntegerList() = readStringList().map(String::toInt)
fun readLongList() = readStringList().map(String::toLong)
