n, m = map(int, input().split())
digit = [list(map(int, input().split())) for _ in range(m)]

for i in range(10**(n-1), 10**n):
  tmp = str(i)
  for s, c in digit:
    if tmp[s-1] != c:
      continue
  print(i)
  exit()
print(-1)
  
