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())
  
  if n == 1:
      ans = 0
      cnt1 = 0
      tmp1 = 0
      for i in range(m):
          s, c = map(int, input().split())
          if s == 1 and cnt1 < 1:
              ans = c
              tmp1 = c
              cnt1 += 1
          elif s == 1 and cnt1 >= 1:
              if tmp1 != c:
                  ans = -1
                  break
              else:
                  cnt1 += 1
          elif s >= 2:
              ans = -1
              break
      print(ans)
  
  if n == 2:
      ans = 0
      cnt10 = 0
      cnt1 = 0
      tmp10 = 0
      tmp1 = 0
      for i in range(m):
          s, c = map(int, input().split())
          if s == 1 and c == 0:
              ans = -1
              break
          if s > 2:
              ans = -1
              break
          elif s == 1 and cnt10 < 1:
              tmp10 = c
              ans += tmp10 * 10
              cnt10 += 1
          elif s == 1 and cnt10 >= 1:
              if c != tmp10:
                  ans = -1
                  break
              else:
                  cnt10 += 1
          elif s == 2 and cnt1 < 1:
              tmp1 = c
              ans += tmp1
              cnt1 += 1
          elif s == 2 and cnt1 >= 1:
              if c != tmp1:
                  ans = -1
                  break
              else:
                  cnt1 += 1
      if ans < 10 and ans != -1:
          ans += 10
      print(ans)
  
  
  if n == 3:
      ans = 0
      cnt100 = 0
      cnt10 = 0
      cnt1 = 0
      tmp100 = 0
      tmp10 = 0
      tmp1 = 0
      for i in range(m):
          s, c = map(int, input().split())
          if s == 1 and c == 0:
              ans = -1
              break
          if s > 3:
              ans = -1
              break
          elif s == 1 and cnt100 < 1:
              tmp100 = c
              ans += tmp100 * 100
              cnt100 += 1
          elif s == 1 and cnt100 >= 1:
              if c != tmp100:
                  ans = -1
                  break
              else:
                  cnt100 += 1
          elif s == 2 and cnt10 < 1:
              tmp10 = c
              ans += tmp10 * 10
              cnt10 += 1
          elif s == 2 and cnt10 >= 1:
              if c != tmp10:
                  ans = -1
                  break
              else:
                  cnt10 += 1
          elif s == 3 and cnt1 < 1:
              tmp1 = c
              ans += tmp1
              cnt1 += 1
          elif s == 3 and cnt1 >= 1:
              if c != tmp1:
                  ans = -1
                  break
              else:
                  cnt1 += 1
      if ans < 100 and ans != -1:
          ans += 100
      print(ans)
  
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"}]