n, m = map(int, input().strip().split())
L = [list(map(int, input().split())) for _ in range(m)]

# if m>n:
#     print(-1)
#     exit()
ans=[None]*n
for l in L:
    if ans[l[0]-1] is None:
        ans[l[0]-1]=l[1]
    elif ans[l[0]-1]!=l[1]:
        print(-1)
        exit()
if ans[0]==0:
    print(-1)
    exit()
for i,v in enumerate(ans):
    if i==0:
        if ans[0] is None:
            ans[0]=1
    elif v is None:
        ans[i]=0
print("".join(list(map(str,ans))))