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

ans = -1
for i in range(10 ** n):
    tmp = str(i)
    if len(tmp) == n:
        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)