output_description: Print the answer.
  
  * * *
input_description: Input is given from Standard Input in the following format:
  
      
      
      N M
      s_1 c_1
      \vdots
      s_M c_M
attempt: bingo = []
  for _ in range(3):
      bingo.append(list(map(int, input().split())))
  
  cl = [[0, 0, 0], [0, 0, 0], [0, 0, 0]]
  
  n = int(input())
  st = set()
  for _ in range(n):
      st.add(int(input()))
  
  for _ in range(len(st)):
      for i in range(3):
          for j in range(3):
              if bingo[i][j] in st:
                  cl[i][j] = 1
  
  if sum(cl[0]) == 3 or sum(cl[1]) == 3 or sum(cl[2]) == 3:
      print("Yes")
  elif sum(cl[:][0]) == 3 or sum(cl[:][1]) == 3 or sum(cl[:][2]) == 3:
      print("Yes")
  elif cl[0][0] + cl[1][1] + cl[2][2] == 3 or cl[0][2] + cl[1][1] + cl[0][2] == 3:
      print("Yes")
  else:
      print("No")
  
problem_description: Statement
  
  If there is an integer not less than 0 satisfying the following conditions,
  print the smallest such integer; otherwise, print `-1`.
  
    * The integer has exactly N digits in base ten. (We assume 0 to be a 1-digit integer. For other integers, leading zeros are not allowed.)
    * The s_i-th digit from the left is c_i. \left(i = 1, 2, \cdots, M\right)
samples: [{"input": "3 3\n    1 7\n    3 2\n    1 7", "output": "702\n    \n\n702 satisfies the conditions - its 1-st and 3-rd digits are `7` and `2`,\nrespectively - while no non-negative integer less than 702 satisfies them.\n\n* * *"}, {"input": "3 2\n    2 1\n    2 3", "output": "-1\n    \n\n* * *"}, {"input": "3 1\n    1 0", "output": "-1"}]