N, M = map(int, input().split())
num = [10] * N
for i in range(M):
    s, c = map(int, input().split())
    if s == 1 and c == 0:
        continue
    num[s-1] = min(num[s-1], c)

num = [[num[i], 0][num[i]==10] for i in range(N)]
if num[0] == 0:
    print(-1)
else:
    print("".join(map(str, num)))
