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