# ANSHUL GAUTAM
# IIIT-D

from math import *
from copy import *
from string import *				# alpha = ascii_lowercase
from random import *				# l.sort(key=lambda l1:l1[0]-l1[1]) => ex: sort on the basis difference
from sys import stdin
from sys import maxsize
from operator import *				# d = sorted(d.items(), key=itemgetter(1))
from itertools import *
from collections import Counter		# d = dict(Counter(l))
from collections import defaultdict # d = defaultdict(list)

'''
3 3
1 7
3 2
1 7
'''

def solve(l):
	n = len(l)
	

N,M = map(int, stdin.readline().rstrip().split())
L = []
out = [-1]*N
f = 0
for m in range(M):
	s,c = list(map(int, stdin.readline().rstrip().split()))
	if(out[s-1] != -1):
		if(str(c) != out[s-1]):
			f = 1
			break
	out[s-1] = str(c)
if(f):
	print(-1)
else:
	# print(out)
	z = ''
	f = 0
	for i in range(len(out)):
		if(out[i] == -1):
			if(i == 0):
				out[i] = '1'
			elif(f):
				out[i] = '0'
			else:
				out[i] = '1'
		if(out[i] != '0'):
			f = 1
	# print(out)
	s = ''.join(out)
	x = str(int(s))
	if(len(x) == N):
		print(x)
	else:
		print(-1)
