n,m=map(int, input().split())
s = [0]*m
c = [0]*m
for i in range(m):
    s[i], c[i] = map(int, input().split())

ans=-1
for i in range(10**(n-1),10**n):
    for j in range(m):
        i=str(i)
        if int(i[s[j]-1])!=c[j]:
            break
    else:
        ans=i
        break
print(ans)