N,M=map(int,input().split())
lst=[]
for i in range(M):
    lst.append(list(map(int,input().split())))
x=' '*N
for i in lst:
    if x[i[0]-1]==' ':
        x=x[:i[0]-1]+str(i[1])+x[i[0]:]
    elif int(x[i[0]-1])!=i[1]:
        x=-1
        break
if type(x)==str:
    if x[0]==' ':
        x='1'+x[1:]
    x=x.replace(' ','0')
    if x[0]=='0' and len(x)!=1:
        x=-1
if M:
    print(x)
else:
    print(-1)