N,M = (int(i) for i in input().split())

SC = []
max_digits = 0
for i in range(M):
  S,C = (int(i) for i in input().split())
  SC.append([S,C])

ans = -1
if M != 0:
  ans = -1
  for i in range(10**(N-1),10**(N)):
    check_flag = True
    for sc in SC:
      s = sc[0]
      c = sc[1]
      if str(i)[s-1] != str(c):
        check_flag = False
        break
    if check_flag is True:
      ans = i
      break
else:
  if N == 1:
    ans = 0
  elif N ==2:
    ans = 10
  elif N == 3:
    ans = 100

print(ans)
