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: n, m = map(int, input().split())
  s = []
  c = []
  for i in range(m):
      news, newc = map(int, input().split())
      s.append(news)
      c.append(newc)
  unchi = -1
  if n == 1:
      for i in range(10):
          hentai = True
          for u in range(m):
              if i != c[u]:
                  hentai = False
          if hentai and unchi == -1:
              unchi = i
  if n == 2:
      num = [1, 0]
      for q in range(9):
          a = q + 1
          for b in range(10):
              num[0] = a
              num[1] = b
              hentai = True
              for u in range(m):
                  if num[s[u] - 1] != c[u]:
                      hentai = False
              if hentai and unchi == -1:
                  unchi = num[0] * 10 + num[1]
  if n == 3:
      num = [1, 0, 0]
      for q in range(9):
          a = q + 1
          for b in range(10):
              for f in range(10):
                  num[0] = a
                  num[1] = b
                  num[2] = f
                  hentai = True
                  for u in range(m):
                      if num[s[u] - 1] != c[u]:
                          hentai = False
                  if hentai and unchi == -1:
                      unchi = num[0] * 100 + num[1] * 10 + num[2]
  print(unchi)
  
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"}]