N,M = [int(zz) for zz in input().split()]

ans = [-1]*N

for _ in range(M):
    s,c = [int(zz) for zz in input().split()]
    if s == 1 and c == 0:
        print(-1)
        exit()
    if ans[s-1] != -1 and c != ans[s-1]:
        print(-1)
        exit()
    else:
        ans[s-1] = c

if ans[0] == -1:
    ans[0] = 1

for i in range(N):
    if ans[i] == -1:
        ans[i] = 0

[print(i,end='') for i in ans]
