N, M = map(int, input().split())
s = [list(map(int, input().split()))for _ in range(M)]

for i in range(10 ** N):
    num = str(i)
    if len(num) == N and all(num[x - 1] == str(y) for x, y in s):
        print(num)
        exit()
print(-1)