n, m = map(int, input().split())
ans = "1" + "0" * (n - 1)
changed_already = [0 for _ in range(n)]
for i in range(m):
    s, c = map(int, input().split())
    if changed_already[s - 1] != 0 and ans[s - 1] != str(c):
        print(-1)
        exit()
    changed_already[s - 1] = 1
    ans = ans[:s - 1]  + str(c) + ans[s:]
if len(str(int(ans))) != n:
    print(-1)
    exit()
print(ans)
