n, m = map(int, input().split())
sc = [tuple(map(int, input().split())) for i in range(m)]
 
for i in range(10**n):
  ans = str(i)
  if len(ans) != n:
    continue
  if all([ans[s-1] == str(c) for s, c in sc]):
    print(ans)
    break
else:
  print(-1)