N,M=map(int,input().split())
s=[]
c=[]
for _ in range(M):
    S,C=map(int,input().split())
    s.append(S)
    c.append(str(C))
ans=[-1]

for i in range(10**(N-1),10**N):
    num=str(i).zfill(N)
    n=list(num)
    cond=0
    for j in range(M):
        if n[s[j]-1]!=c[j]:
            cond=1
            break
    if cond==0:
        ans=n
        break

if ans[0]==-1:
    print(-1)
else:
    for k in range(N):
        print(ans[k],end="")