rank,n = map(int,input().split())
num = [-1 for i in range(rank)]
cond = True
for i in range(n):
    s,c = map(int,input().split())
    if s > rank:
        print(-1)
        cond = False
        break
    elif num[s-1+(rank-3)] == -1 or num[s-1+(rank-3)] == c:
        print(s-1+(rank-3),c)
        num[s-1+(rank-3)] = c
    else:
        print(-1)
        cond = False
        break

if num[0] == 0:
    cond = False
    print(-1)

if cond == True:
    if num[0] == -1:
        num[0] = 1
    for i in range(rank-1):
        if num[i+1] == -1:
            num[i+1] = 0
    print(num)
    if rank == 3:
        print(num[0]*100+num[1]*10+num[2])
    elif rank == 2:
        print(num[0]*10+num[1])
    else:
        print(num[0])
