N, M = map(int, input().split())

guess = []
for _ in range(M):
  s, c = map(int, input().split())
  guess.append([s, c])

for n in range(pow(10, N)):
  if (len(str(n)) != N):
    continue
  
  valid = True
  for s_c in guess:
    keta = s_c[0]
    index = keta - 1
    if (str(n)[index] != str(s_c[1])):
      valid = False
      break
  
  if (valid == False):
    continue
  else:
    print(n)
    return

print(-1)