package main

import (
	"fmt"
)

func main() {
	var n, m int
	fmt.Scan(&n, &m)
	as := make([]int, n)
	for i := range as {
		as[i] = -1
	}
	for i := 0; i < m; i++ {
		var s, c int
		fmt.Scan(&s, &c)
		s--
		if (as[s] != -1 && c != as[s]) || (s == 0 && c == 0) {
			fmt.Println(-1)
			return
		}
		as[s] = c
	}
	for i := range as {
		if as[i] == -1 {
			if i == 0 {
				fmt.Print(1)
			} else {
				fmt.Print(0)
			}
		} else {
			fmt.Print(as[i])
		}
	}
	fmt.Println()
}
