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

res = [0] * N

for _ in range(M):
    i, n = map(int, input().split())
    res[i - 1] = n

tmp = ""
for i in range(N):
    tmp += str(res[i])

if len(str(int(tmp))) == N:
    print(int(tmp))
else:
    print("-1")