N, M = map(int, input().split())
sc = [tuple(map(int, input().split())) for i in range(M)]

for i in range(10**N):
  n = str(i)
  if len(n) != N: continue
  if all([n[s-1] == str(c) for s, c in sc]):
    print(n)
    break
else:
  print(-1)
