n,m=map(int,input().split())
L=[[] for i in range(n)]
for i in range(m):
    s,c=map(int,input().split())
    L[s-1].append(c)
k=0
#print(L)
for i in range(n):
    if len(set(L[i]))>1:
        k=1
if L[0]==[0]:
    k=1
if k==1:
    print(-1)
else:
    for i in range(n):
        if not(L[i]):
            if i==0:
                print(1,end='') 
            else:
                print(0,end='')
        else:
            print(L[i][0],end='')                           