N, M = map(int, input().split())
SC = set(tuple(map(int, input().split())) for _ in range(M))

for i in range(10**N):
    num = str(i)
    if len(num) != N:
        continue
    chk = True
    for s, c in SC:
        print(s, c, num)
        if num[s-1] != str(c):
            chk = False
    if chk == True:
        print(num)
        exit()
print(-1)