from sys import exit
N, M = map(int, input().split())
sc = [list(map(int, input().split())) for i in range(M)]
for n in range(10**N):
  if len(str(n)) == N and all(str(n)[s - 1] == str(c) for s, c in sc):
    print(n)
    exit()
print(-1)