n, m = [int(i) for i in input().split(" ")]
sc = []
for i in range(m):
  sc.append([int(j) for j in input().split(" ")])

for i in range(10**(n-1), 10**(n), 1):
  f = True
  for con in sc:
    if str(i)[con[0]-1] != str(con[1]):
      f = False
  if f :
    print(i)
    break
else:
  print(-1)