N, M = map(int, input().split())

hints = []
for _ in range(M):
  a, b = map(int, input().split())
  hints.append((a, b))
  
def solve(n, hints):
  for i in range(10 ** (N + 1)):
    s = str(i)
    if all(len(s) == N and s[hint[0] - 1] == str(hint[1]) for hint in hints):
      return i
  return -1
      
print(solve(N, hints))  