import sys
input = lambda: sys.stdin.readline().rstrip()
n,m=map(int,input().split())
a=[0]*n
for _ in range(m):
    i,j=map(int,input().split())
    a[i-1]=j
num=str(int(''.join(map(str,a))))
if n==len(num): print(num)
else: print(-1)
