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

ans = [-1] * N
for s, c in SC:
    if ans[s-1] == -1:
        ans[s-1] = c
if N >= 2:
    if ans[0] == -1 or ans[0] == 0:
        print(-1)
        exit()
kotae = ''
for a in ans:
    if a == -1:
        kotae += '0'
    else:
        kotae += str(a)
print(kotae)