output_description: Print the answer.
  
  * * *
input_description: Input is given from Standard Input in the following format:
  
      
      
      N
attempt: a = input().split(" ")
  N = int(a[0])
  M = int(a[1])
  ans1 = 10
  ans2 = 10
  ans3 = 10
  for i in range(M):
      b = input().split(" ")
      c = int(b[0])
      d = int(b[1])
      if c == 1:
          if d == 0:
              if N == 1:
                  ans1 = d
          elif d < ans1:
              ans1 = d
      elif c == 2:
          if d < ans2:
              ans2 = d
      else:
          if d < ans3:
              ans3 = d
  if ans1 == 10:
      ans1 = 0
  if ans2 == 10:
      ans2 = 0
  if ans3 == 10:
      ans3 = 0
  if N == 1:
      print(ans1)
  elif N == 2:
      if ans1 == 0:
          print(-1)
      else:
          print(str(ans1) + str(ans2))
  else:
      if ans1 == 0:
          print(-1)
      else:
          print(str(ans1) + str(ans2) + str(ans3))
  
problem_description: Statement
  
  Takahashi wants to print a document with N pages double-sided, where two pages
  of data can be printed on one sheet of paper.
  
  At least how many sheets of paper does he need?
samples: [{"input": "5", "output": "3\n    \n\nBy printing the 1-st, 2-nd pages on the 1-st sheet, 3-rd and 4-th pages on the\n2-nd sheet, and 5-th page on the 3-rd sheet, we can print all the data on 3\nsheets of paper.\n\n* * *"}, {"input": "2", "output": "1\n    \n\n* * *"}, {"input": "100", "output": "50"}]