n, m = map(int, input().split())
s = [0] * m
c = [-1] * m
ans = [-1] * n
for i in range(m):
    s[i], c[i] = map(int, input().split())
    if n >= 2 and s[i] == 1 and c[i] == 0:
        print(-1)
        exit()
    if ans[s[i] - 1] != -1 and ans[s[i] - 1] != c[i]:
        print(-1)
        exit()
    if ans[s[i] - 1] == -1:
        ans[s[i] - 1] = c[i]

if n == 1:
    print(ans[0])
else:
    if ans[0] == -1:
        ans[0] = 1
    for i in range(1, n):
        if ans[i] == -1:
            ans[i] = 0

print("".join(map(str, ans)))
