n,m = map(int,input().split())
lists = [list(map(int,input().split())) for i in range(m)]
keta = ["0"]*n
for i,j in lists:
    keta[i-1] = str(j)
num = "".join(keta)
ans = int(num)
str_ans = str(ans)
if len(str_ans) == 3:
    print(str_ans)
else:
    print(-1)