n,m = map(int, input().split())

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

for i in range(1,1000):
    flag = 0
    I = str(i)
    if len(I)==n:
        for j in range(len(lst)):
            if I[lst[j][0]-1]!=lst[k][1]:
                flag = 1
        if flag == 0:
            print(I)
print(-1)