N, M = map(int, input().split())
S = [0 for i in range(M)]
C = [0 for i in range(M)]
for i in range(M):
    S[i], C[i] = list(map(int, input().split()))

flg = [False for i in range(N)]
ans = [1]
for i in range(N - 1):
    ans.append(0)

for s, c in zip(S, C):
    if s - 1 == 0 and c == 0:
        print(-1)
        break
    elif flg[s - 1] == True and c != ans[s - 1]:
        print(-1)
        break
    else:
        flg[s - 1] = True
        ans[s - 1] = c
else:
    print(''.join([str(a) for a in ans]))