n, m = map(int, input().split())

result = []
for _ in range(n):
  result.append(-1)

for _ in range(m):
  s, c = map(int, input().split())
  if result[s-1] not in [-1, c]:
    print(-1)
    exit()
  else:
    result[s-1] = c

for _ in range(len(result)):
  if result[_] == -1:
    result[_] = 1
  
result = map(str, result)
result = "".join(result)
  
print(result)
  