n, m = map(int, input().split())
sc = [[int(i) for i in input().split()] for i in range(m)]
sc.sort()
ans = 0
answer = 0
if sc[0][0] != 1 or sc[0][1] == 0:
    answer = -1
else:
    ans = [0] * n
    for i in range(m):
        r = sc[i][0] - 1
        ans[r] = sc[i][1]

    for j in range(n):
        answer += ans[j] * 10 ** (n - j - 1)
print(int(answer))

