N, M = map(int, input().split())
ls = [0] * N

for _ in range(M):
    s, c = map(int, input().split())
    if ls[s-1] != c:
        ls[s-1] = c

ans = ''.join(map(str, ls))

if len(str(int(ans))) == N:
    print(ans)
else:
    print(-1)
