'''
INPUT SHORTCUTS
N, K = map(int,input().split())
N ,A,B = map(int,input().split())
string = str(input())
arr = list(map(int,input().split()))
N = int(input())
'''
n , m = map(int,input().split())
dp = [-1 for _ in range(n)]
flag = True 
for _ in range(m):
	i , val =  map(int,input().split())
	if dp[i-1] == -1:
		dp[i-1]=val
	elif dp[i-1]!=val:
		flag = False
		# print(dp[i-1])
		break
if dp[0]==0:
	flag = False
if flag:
	for i in range(n):
		if dp[i]==-1:
			dp[i]=0
	if dp[0]==0:
		dp[0]=1
	for x in dp:
		print(str(x),end="")
else:
	print("-1")