N,M=map(int,input().split())
flag_n=[-1 for i in range(N)]
ans="1"+"0"*(N-1)
flag=True
for i in range(M):
    digit, num=map(int,input().split())
    if flag_n[digit-1]==-1 :
        flag_n[digit-1]=num
        ans=ans[digit-1:]+str(num)+ans[digit:]
    elif flag_n[digit-1]!=num:
        flag=False
        break
if False:
    print(-1)
elif N>1 and ans[0]=="0":
    print(-1)
else:
    print(int(ans))