# -*- coding: utf-8 -*-
import sys
import math
#import collections
#sys.setrecursionlimit(100000)

tmp = input().split()
n,m = list(map(lambda a: int(a), tmp))

a=[]
for i in range(n):
	a.append(-1)

for i in range(m):
	tmp = input().split()
	s,c = list(map(lambda a: int(a), tmp))
	if(a[s-1]!=c)and(a[s-1]!=-1):
		print(-1)
		sys.exit()
	a[s-1]=c

if(a[0]==0):
		print(-1)
		sys.exit()

ans=0
for i in range(n):
	if(a[i]==-1):
		if(i==0):
			a[i]=1
		else:
			a[i]=0
	ans*=10
	ans+=a[i]
print(ans)






