# -*- coding: utf-8 -*-

N, M =  [int(i) for i in input().split()]

S = []
for i in range(M):
    S.append([int(i) for i in input().split()])

answer = "0" * N

for s in S:
    if answer[int(s[0])-1] != s[1]:
        print(-1)
    else:
        answer = answer[:int(s[0])-1] + str(s[1]) + answer[int(s[0]):]
if answer[0] == "0":
    print(-1)
else:
    print(answer)
