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

digits = {}
for i in range(M):
    s, c = tuple(map(int, input().split()))
    digits[s] = c

num = 0

for s, c in digits.items():
    num += 10 ** (s - 1) * c

num = int(str(num)[::-1])

length = len(str(num))

if length >= N:
    print(num)
else:
    print(-1)
