package main
import "fmt"
import "unicode/utf8"
import "strconv"
func main(){
    // Your code here!
    var n, m int
    fmt.Scan(&n, &m)
    t := make([][]int, m)
    var t1, t2 int
    for i := 0; i < m; i++ {
         fmt.Scan(&t1, &t2)
         t[i] = []int{t1, t2}
    }
    // fmt.Println(n)
    // fmt.Println(t)
    
    var ss string
    for i := 0; i <= 999; i++{
        ss = strconv.Itoa(i)
        //fmt.Println(utf8.RuneCountInString(ss))
        if utf8.RuneCountInString(ss) != n{
            continue
        }
        //println(string(ss[0]))
        var f bool
        f = true
        for k := 0; k < len(t); k++{
            //println(string(ss[t[k][0]-1]), t[k][1])
            if string(ss[t[k][0]-1]) != strconv.Itoa(t[k][1]){
                f = false
            }
        }
        if f == true{
            println(ss)
            return
        }
    }
    println("-1")
}
