N, M = map(int, input().split())
SC = [tuple(map(int, input().split())) for i in range(M)]

for i in range(10**N):
    ans = str(i)
    if len(ans) != N:
        continue
    if all(ans[si-1] == str(ci) for si, ci in SC ):
        print(ans)
        exit()

print(-1)
