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

for i in range(1000):
  t = str(i)
  if len(t) != n: continue
  judge = True
  for s, c in sc:
    if t[s-1] != str(c):
      judge = False
  if judge:
    print(t)
    exit(0)
print(-1)