N,M=map(int,input().split())
S_C=[list(int(x) for x in input().split()) for _ in range(M)]

for i in range(10**N):
    i=str(i)
    if len(i)!=N:
        continue
    if all([i[s-1]==str(c) for s,c in S_C]):
        print(i)
        exit()
print(-1)
