import sys
n, m = map(int, input().split())
ans = [-1]*n
for _ in range(m):
    s, c = map(int, input().split())
    if ans[s-1] == -1 or ans[s-1] == c:
        ans[s-1] = c
    if s == 0 and c == 0:
        print(-1)
        sys.exit()
    else:
        print(-1)
        sys.exit()

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