output_description: Print Q lines. The i-th line should contain the distance the i-th person will
  walk or -1 if that person walks forever.
  
  * * *
input_description: Input is given from Standard Input in the following format:
  
      
      
      N Q
      S_1 T_1 X_1
      :
      S_N T_N X_N
      D_1
      :
      D_Q
attempt: # coding: utf-8
  
  
  class Construction:
      def __init__(self, start, end, pos):
          self.start = start - 0.5
          self.end = end - 0.5
          self.pos = pos
          self.working = False
  
  
  class Constructions:
      def __init__(self):
          self.list = []
          self.start_max = 0
  
      def append(self, construction):
          self.list.append(construction)
          if self.start_max < construction.start:
              self.start_max = construction.start
  
      def sort(self):
          self.list = sorted(self.list, key=lambda x: x.start)
  
      def __iter__(self):
          for c in self.list:
              yield c
  
      def isEncounter(self, pos):
          for c in self.list:
              if c.working and pos == c.pos:
                  return True
          return False
  
      def __str__(self):
          return str([(c.start, c.end, c.pos, c.working) for c in self.list])
  
      def step(self, elapsed_time):
          for c in self.list:
              if c.start <= elapsed_time and c.end >= elapsed_time:
                  c.working = True
              else:
                  c.working = False
  
  
  class Person:
      def __init__(self, departure):
          self.departure = departure
          self.pos = 0
          self.walking = True
  
      def walk(self):
          if self.walking:
              self.pos += 1
  
      def stop(self):
          self.walking = False
  
  
  class Persons:
      def __init__(self):
          self.list = []
          self.departure_max = 0
  
      def append(self, person):
          self.list.append(person)
          if self.departure_max < person.departure:
              self.departure_max = person.departure
  
      def __iter__(self):
          for p in self.list:
              yield p
  
      def __str__(self):
          return str([(p.departure, p.pos) for p in self.list])
  
  
  input_line = input()
  construction_num, person_num = map(int, input_line.split())
  
  constructions = Constructions()
  for i in range(construction_num):
      input_line = input()
      start, end, pos = map(int, input_line.split())
      c = Construction(start, end, pos)
      constructions.append(c)
  
  persons = Persons()
  for i in range(construction_num):
      input_line = input()
      departure = int(input_line)
      p = Person(departure)
      persons.append(p)
  
  constructions.sort()
  
  elapsed_time = 0
  while True:
      for index, p in enumerate(persons):
          constructions.step(elapsed_time)
          if constructions.isEncounter(p.pos):
              p.stop()
  
          if p.pos > constructions.start_max:
              p.stop()
              p.pos = -1
  
          if p.departure <= elapsed_time:
              p.walk()
  
      elapsed_time += 1
      if any([p.walking for p in persons]) == False:
          break
  
  for p in persons:
      print(p.pos)
  
problem_description: Statement
  
  There is an infinitely long street that runs west to east, which we consider
  as a number line.
  
  There are N roadworks scheduled on this street. The i-th roadwork blocks the
  point at coordinate X_i from time S_i - 0.5 to time T_i - 0.5.
  
  Q people are standing at coordinate 0. The i-th person will start the
  coordinate 0 at time D_i, continue to walk with speed 1 in the positive
  direction and stop walking when reaching a blocked point.
  
  Find the distance each of the Q people will walk.
samples: [{"input": "4 6\n    1 3 2\n    7 13 10\n    18 20 13\n    3 4 2\n    0\n    1\n    2\n    3\n    5\n    8", "output": "2\n    2\n    10\n    -1\n    13\n    -1\n    \n\nThe first person starts coordinate 0 at time 0 and stops walking at coordinate\n2 when reaching a point blocked by the first roadwork at time 2.\n\nThe second person starts coordinate 0 at time 1 and reaches coordinate 2 at\ntime 3. The first roadwork has ended, but the fourth roadwork has begun, so\nthis person also stops walking at coordinate 2.\n\nThe fourth and sixth persons encounter no roadworks while walking, so they\nwalk forever. The output for these cases is -1."}]