n, m = [int(i) for i in input().split()]
res = [0 for _ in range(n)]
for _ in range(m):
  a, b = [int(i) for i in input().split()]
  if res[a-1] != 0 and res[a-1] != b:
    print(-1)
    exit()
  elif a == 1 and b == 0:
    print(-1)
    exit()
  res[a-1] = b
print(''.join([str(r) for r in res]))
