n,m = map(int, input().split())
lst = []
for i in range(m):
    s,c = map(int, input().split())
    lst.append((s-1,c))

if n!=1:
    for i in lst:
        if i==(1,0):
            print(-1)
            exit()

# print(lst)

for i in range(10**(n-1),10**n):
    I = str(i)
    flag = 0
    for j in lst:
        if I[j[0]]!=str(j[1]):
            flag = 1
    if flag == 0:
        print(I)
        exit()

print(-1)
