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

for i in range(10**n):
  k = str(i)
  if len(str(i)) == n:
    if all(str(i)[s-1] == str(c) for s, c in sc):
      print(i)
      exit()
print(-1)