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

ans = str(int(''.join(map(str, res))))
if len(ans) != n:
    print(-1)
else:
    print(ans)