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