import sys
n, m = map(int, input().split())
lis = [list(map(int, input().split())) for _ in range(m)]
ans = -1
i = 10**(n-1)
while (ans == -1) and (i < 10**n):
    s = 0
    for j in lis:
        if str(i)[j[0]-1] == str(j[1]):
            s += 1
        else:
            s += 0
    if s == m:
        ans = i
        exit()
    else:
        i += 1
print(ans)