N,M = map(int,input().split())
li =[]
for i in range(M):
    li.append(list(map(int,input().split())))
    if li[i][0]>N:
        print("-1")
        exit()
print(li)
for i in range(10**(N-1),10**N):
    inv = True
    a = str(i)
    for j in range(M):
        if  a[li[j][0]-1] != str(li[j][1]):
            inv = False
    if inv:
        print(i)
        exit()
print("-1")