n,m = map(int,input().split())
raw = []
for _ in range(m):
  s,c = map(int,input().split())
  s -= 1
  raw.append([s,c])
for d in range(1000):
  e = str(d)
  e = '0' * (n-len(e)) + e
  #print(e)
  for x in raw:
    s,c = x
    if e[s] != str(c):
      break
  else:
    if e[0] == '0':
      continue
    else:
      print(e)
      break
  continue
else:
  print(-1)