n,m = map(int, input().split())
sc = [map(int, input().split()) for _ in range(m)]
s, c = [list(i) for i in zip(*sc)]



for i in range(10**n):
    ans = str(i)
    if len(i) == n and all([i[s[j]-1] == str(c[j]) for j in range(m)]):
        print(ans)
        exit()


print(-1)