n, m = map(int, input().split())
s = []
c = []
for i in range(m):
    S, C = map(int, input().split())
    s.append(S)
    c.append(C)

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

print(-1)