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

for i in range(10**(n-1), 10**n):
    n = str(i)
    for s,c in reqs:
        if s-1 >= len(n) or n[s-1] != str(c):
            break
    else:
        print(i)
        break
else:
    print(-1)
