n,m = list(map(int, input().split()))
l=[list(map(int, input().split())) for _ in range(m)]
ans=[str(i) for i in range(10**(n-1),10**n)]
for s,c in l:
    ans = [k for k in ans if k[s-1]==str(c)]

if ans:
    print(ans[0])
else:
    print(-1)