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
if n==1 and a[0]==0: 
    print(0)
    exit(0)
j=0
while j<len(a):
    if a[j]==0:
        a.pop(0)
    else: break
if len(a)<n: print(-1)
else: print(''.join(map(str,a)))

    