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

for i in range(10**(n-1),10**n):
    p = list(map(int,list(str(i))))
    for s,c in li:
        if p[s-1] != c:break
    else:
        print(i)
        break
else:print(-1)