N, M = map(int, input().split())
SC = [list(map(int, input().split())) for _ in range(M)]
i = 10**(N-1)
while i < 10**N:
  n = [(i//10**j)%10  for j in reversed(list(range(N)))]
  f = True
  for s, c in SC:
    if n[s-1] != c:
      f = False
  if f:
    break
  i += 1
if i >= 10**N:
  print(-1)
else:
  print(i)