import sys

n, m = map(int, input().split())
s = []
c = []
exist = False
for _ in range(m):
  t_s, t_c = map(int, input().split())
  if t_s == 1:
    exist = True
    if t_c == 0:
      print(-1)
      sys.exit(0)

  s.append(t_s)
  c.append(t_c)

if not exist:
  print(-1)
  sys.exit(0)
result = [0 for _ in range(n)]
for i in range(m):
  result[s[i] - 1] = c[i]

print(''.join([str(x) for x in result]))