N,M = map(int,input().split())

li = [list(map(int,input().split())) for i in range(M)]

for i in range(10**(N-1),10**N):
    num = str(i)
    for o  in li:
        s,c = o
        if not num[s-1]==str(c):

            break

    else:
        print(i)
        exit()


print(-1)