N,M = list(map(int,input().split()))
sc = [input().split() for i in range(M)]
t = 1
for i in range(10**N):
    i = str(i).split()
    for j in range(M):
        t *= (i[sc[j][0]] == sc[j][1])
    if t == 1:
        print(i)
    break
    else:
        print(-1)