n,m = map(int,input().split())
s = []
c = []
for i in range(m):
    ss,cc = map(int,input().split())
    s.append(ss)
    c.append(cc)
for i in range(10**(n-1) if n>1 else 0,10**n):
    ans = str(i)
    for j in range(m):
        if ans[s[j]-1] != str(c[j]):
            break
        else:
            print(ans)
print(-1)