n, m = map(int, input().split())
ans = [None] * n
for i in range(m):
    s, c = map(int, input().split())
    if (ans[s - 1] is not None and ans[s - 1] != c) or (s == 1 and c == 0):
        ans = -1
        break
    ans[s - 1] = c
if ans != -1:
    if ans[0] is None:
        ans[0] = 1
    for i in range(1, n):
        if ans[i] is None:
            ans[i] = 0
    ans = ''.join(list(map(str, ans)))
print(ans)
