package main

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

func main() {
	buf.Split(bufio.ScanWords)

	n := scanInt()
	m := scanInt()
	sc := make([][]int, m)
	for i := range sc {
		s := scanInt()
		c := scanInt()
		sc[i] = []int{s, c}
	}

	number := make([]int, n)
	for i := range number {
		number[i] = -1
	}

	for i := 0; i < len(sc); i++ {
		index := sc[i][0] - 1
		if number[index] == -1 {
			number[index] = sc[i][1]
		} else if number[index] != sc[i][1] {
			fmt.Printf("%d", -1)
			return
		}
	}

	for i := 0; i < len(number); i++ {
		if number[i] == 0 && i == 0 && n != 1 {
			fmt.Printf("%d", -1)
			return
		}
		if number[i] == -1 {
			if i == 0 {
				number[i] = 1
			} else {
				number[i] = 0
			}
		}
	}

	answer := ""
	for _, digit := range number {
		answer += strconv.Itoa(digit)
	}
	fmt.Printf("%s", answer)
}

var buf = bufio.NewScanner(os.Stdin)

func scanInt() int {
	buf.Scan()
	i, _ := strconv.Atoi(buf.Text())
	return i
}

func scanInts(n int) []int {
	a := make([]int, n)
	for k, _ := range a {
		a[k] = scanInt()
	}
	return a
}

func scanString() string {
	buf.Scan()
	return buf.Text()
}

func scanStrings(n int) []string {
	a := make([]string, n)
	for k, _ := range a {
		a[k] = scanString()
	}
	return a
}
