N, M = map(int, input().split())
if M == 0:
  if N == 1:
    print('0')
  else:
    m = 10 ** (N - 1)
    print(str(m))
else:
  dic = {}
  t = ''
  for _ in range(M):
    s, c = map(int, input().split())
    if s not in dic:
      dic[s] = c
    else:
      print(-1)
      break
  if 1 in dic:
    if dic[1] == 0:
      print(-1)
    else:
      t += str(dic[1])
  for j in range(2, 10):
    if j in dic:
      t += str(dic[j])
    else:
      t += '0'
  print(t)