# coding: utf-8
# Your code here!
import sys

n, m = map(int, input().split())
sc = [list(map(int, input().split())) for f in range(m)]
for i in range(10**(n-1), 10**n):
  x = False
  for j in sc:
    if str(i)[j[0]-1] != str(j[1]):
      x = True
      break
  if x:
    continue
  print(i)
  sys.exit()
print(-1)  