n, m = map(int, input().split())
lst = [list(map(int, input().split())) for _ in range(m)]

ans = -1
for i in range(10 ** (n - 1) - 1, 10 ** n):
    tmp = str(i)
    flg = False
    for l in lst:
        if tmp[l[0] - 1] == str(l[1]):
            flg = True
            break
    if flg == True:
        ans = i
        break

print(ans)