n, m = [int(i) for i in input().split()]
res = [-1 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
if res[0] == -1:
  res[0] = 1
for i in range(1,n):
  if res[i] == -1:
    res[i] = 0
print(''.join([str(r) for r in res]))
