package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

func main() {
	scan_init()
	N := scanInt()
	M := scanInt()
	s := make([]int,M)
	c := make([]int,M)
	for i:= 0; i<M;i++ {
		s[i] = scanInt()
		c[i] = scanInt()
	}
	 output := make([]int,N)
	 for i:= 0; i<N; i++ {
	 	output[i] = 10 //10で初期化しとく
	 }
	 umakuita := true
	 for i:= 0; i<M; i++ {
	 	keta := s[i]-1
	 	if output[keta] == c[i] || output[keta] == 10 {
	 		output[keta] = c[i]
		} else {
			umakuita = false
			break
		}
	 }
	 for i:= 0; i<N; i++ {
	 	if output[i] == 10 {
	 		if i== 0 {
	 			output[i] = 1
			} else {
				output[i] = 0
			}
	 	}
	 }
	 if output[0] == 0 {
	 	umakuita = false
	 }
	 if umakuita {
	 	for i:= 0; i<N; i++ {
	 		fmt.Print(output[i])
		}
	 } else {
	 	fmt.Println(-1)
	 }
}
var sc = bufio.NewScanner(os.Stdin)
func scan_init () {
	sc.Split(bufio.ScanWords)
}
func scanInt () int{
sc.Scan()
	i,_ := strconv.Atoi(sc.Text())
	return i
}
func scan () string{
 sc.Scan()
	return sc.Text()
}
