NM = list(map(int,input().split()))
N = NM[0]
M = NM[1]
SC = []
temp = [0] * N
test = True
for i in range(M):
    SC.append(list(map(int,input().split())))
    Ldigit = SC[i][0]
    Lnum = SC[i][1]
    temp[Ldigit-1] = Lnum
print(SC)
print(temp)
tempS = "".join(map(str,temp))
for i in range(999):
    if str(i) == tempS:
        print(i)
        test = False
if test:
    print(-1)