N,M=map(int,input().split())
flag_n=[-1 for i in range(N)]
ans="1"+"0"*(N-1)

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:
        ans="-1"
        break
print("-1") if ans=="0"*N else print(ans)