
N, M = map(int, input().split())

ans = [0] * N

for i in range(M):
    si,ci = map(int, input().split())
    if ans[si-1] > ci or ans[si-1] == 0:
        ans[si-1] = ci

if ans[0] > 0:
    print( ''.join(map(str, ans)) )
else:
    print(-1)
