#!/usr/bin/python3.7
# -*- coding: utf-8 -*-

#ABC157C

b = False
n, m = list(map(int, input().split()))
sc = {}
for i in range(m):
	s, c = list(map(int, input().split()))
	if s not in sc:
		sc[s] = str(c)
	elif sc[s] != str(c):
		b = True

if b:
	print(-1)
else:
	ans = ''
	for i in range(1, n+1):
		if i not in sc:
			if i == 1:
				sc[i] = str(1)
			else:
				sc[i] = str(0)
		ans += sc[i]
	ans = str(int(ans))
	if len(ans) == n:
		print(ans)
	else:
		print(-1)














