fun main(args: Array<String>) {
    val (n, m) = readLongList()
    val conditionArray = Array(m.toInt()) { readIntegerList() }
    val first = if (n == 1L) 0 else pow(10, n - 1, Long.MAX_VALUE)
    for (i in first 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 {
    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)
