n, m = map(int, input().split())
x = [list(map(int, input().split())) for i in range(m)]
count = 0
for i in range(1000):
    count = 0
    i = str(702)
    if len(i) == n:
        for s, c in x:
            if i[s-1] == str(c):
                count += 1
            else:
                break
        if count == m:
            print(i)
            exit()
print(-1)