n, m = map(int, input().split())
num = {}
for i in range(m):
    s, c = map(int, input().split())
    if s == 1 and c == 0:
        print(-1)
        exit()
    elif s not in num:
        num[s] = c
    elif s in num and num[s] != c:
        print(-1)
        exit()

num2 = [1] + [0]*(n-1)
for j in num.keys():
    num2[j - 1] = num[j]
print(int("".join(map(str, num2))))
