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

t = 10 ** (N - 1)
e = t * 10

for i in range(t, e):
  k = list(str(i))
  for s, c in sc:
    if int(k[s - 1]) != c:
      break
  else:
    print(i)
    exit()
print(-1)