package main

import (
	"fmt"
	"math"
)

func solution(n, m int, nums [][]int) int {
	tmp := make([]int, n)
	for i := 0; i < m; i++ {
		tmp[nums[i][0]-1] = nums[i][1]
	}
	if tmp[0] == 0 {
		return -1
	}
	var ans int
	for i := 0; i < n; i++ {
		ans += int(math.Pow10(2-i)) * tmp[i]
	}
	return ans
}

func main() {
	var n, m, s, c int
	fmt.Scan(&n, &m)
	nums := make([][]int, m)
	for i := range nums {
		nums[i] = make([]int, 2)
	}
	for i := 0; i < m; i++ {
		fmt.Scan(&s, &c)
		nums[i][0] = s
		nums[i][1] = c
	}

	fmt.Println(solution(n, m, nums))
}
