n,m = list(map(int,input().split()))
ans_l = ["0" for _ in range(n)]
#print(ans_l)
flag = True
for i in range(m):
    s,c, =list(map(int,input().split()))
    if n>=2:
        if s==1 and c==0:
            flag = False
            break
    if not ans_l[s-1]=="0":
        if ans_l[s-1]!=c:
            flag=False
            break
    ans_l[s-1]=c
if ans_l[0]==0:
    ans_l[0]=1

if flag:
    for i in ans_l:
        print("{:}".format(i),end="")
    print()
else:
    print("-1")