import java.io.PrintWriter
import java.util.StringTokenizer

fun main() {

    fun PrintWriter.solve() {
        var (n,m) = List(2){nextInt()}
        var arr = IntArray(n){-1}

        repeat(m){
            var (s,c) = List(2){nextInt()}
            s--
            if (arr[s] == -1 || arr[s] == c){
                arr[s] = c
            }
            else{
                println(-1)
                return
            }
        }

        if (arr[0] == -1)arr[0] = 1
        arr.indices.forEach { if(arr[it] == -1) arr[it] = 0 }

        if (n != 1 && arr[0] == 0){
            println(-1)
            return
        }
        println(arr.joinToString("") )



    }

    writer.solve()
    writer.flush()


}


private val reader = System.`in`.bufferedReader()
private val writer = PrintWriter(System.out, false)

private var tokenizer: StringTokenizer = StringTokenizer("")

private fun next(): String {
    while (tokenizer.hasMoreTokens().not()) tokenizer = StringTokenizer(reader.readLine())
    return tokenizer.nextToken()
}

private fun nextInt() = next().toInt()
private fun nextLong() = next().toLong()
private fun nextDouble() = next().toDouble()
private fun nextLine() = reader.readLine()

