N , M = map(int,input().split())
ans = ["0" for _ in range(N)]
for i in range(M):
    s , c = map(int,input().split())
    ans[s - 1] = str(c)
if len(str(int("".join(ans)))) == N:
    print(int("".join(ans)))
else:
    print("-1")