package main

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

const (
	initialBufSize = 10000
	maxBufSize     = 1000000
)

var (
	sc *bufio.Scanner = func() *bufio.Scanner {
		sc := bufio.NewScanner(os.Stdin)
		buf := make([]byte, initialBufSize)
		sc.Buffer(buf, maxBufSize)
		sc.Split(bufio.ScanWords)
		return sc
	}()
	mod int = 1e9 + 7
)

func main() {
	N := getInt()
	M := getInt()

	s := make([]int, M)
	c := make([]int, M)

	for i := 0; i < M; i++ {
		s[i] = getInt() - 1
		c[i] = getInt()
	}

	result := make([]int, N)
	for i := 0; i < N; i++ {
		result[i] = -1
	}

	for i := 0; i < M; i++ {
		if N != 1 && s[i] == 0 && c[i] == 0  {
			fmt.Println(-1)
			return
		}

		if result[s[i]] != -1 {
			if result[s[i]] != c[i] {
				fmt.Println(-1)
				return
			}
		}

		result[s[i]] = c[i]
	}

	str := ""
	for i := 0; i < N; i++ {
		if result[i] == -1 {
			if i == 0 {
				str += "1"
			} else {
				str += "0"
			}
		} else {
			str += strconv.Itoa(result[i])
		}
	}

	fmt.Println(str)
}

func getInt() int {
	sc.Scan()
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}

func getString() string {
	sc.Scan()
	return sc.Text()
}

func abs(a int) int {
	return int(math.Abs(float64(a)))
}

func pow(p, q int) int {
	return int(math.Pow(float64(p), float64(q)))
}

func powMod(n, p int) int {
	if p == 0 {
		return 1
	} else if p % 2 == 0 {
		t := powMod(n, p / 2)
		return calcMod(t * t)
	} else {
		return n * powMod(n, p - 1)
	}
}

func min(nums ...int) int {
	if len(nums) == 0 {
		panic("funciton min() requires at least one argument.")
	}
	res := nums[0]
	for i := 0; i < len(nums); i++ {
		res = int(math.Min(float64(res), float64(nums[i])))
	}
	return res
}

func max(nums ...int) int {
	if len(nums) == 0 {
		panic("funciton max() requires at least one argument.")
	}
	res := nums[0]
	for i := 0; i < len(nums); i++ {
		res = int(math.Max(float64(res), float64(nums[i])))
	}
	return res
}

func strSearch(a []string, b string) bool {
	for i := 0; i < len(a); i++ {
		if a[i] == b {
			return true
		}
	}
	return false
}

func printIntArray(array []int) {
	strArray := fmt.Sprint(array)
	fmt.Println(strArray[1 : len(strArray) - 1])
}

func calcMod(x int) int {
	return x % mod
}
