a = -1
n,m = map(int, input().split())
s_and_c = [tuple(map(int,input().split())) for i in range(m)]
l = [0]*m
for t in s_and_c:
  l[t[0]-1] = t[1]
if len(l) == n:
  a = "".join([str(i) for i in l])
else:
  pass
print(a)