output_description: For each query, output in a line the era name and the era-based year number
  corresponding to the western year given, separated with a single whitespace.
  In case you cannot determine the era, output “Unknown” without quotes.
input_description: The input contains multiple test cases. Each test case has the following
  format:
  
  _N Q_  
  _EraName_ 1 _EraBasedYear_ 1 _WesternYear_ 1  
  .  
  .  
  .  
  _EraName_ _N_ _EraBasedYear_ _N_ _WesternYear_ _N_  
  _Query_ 1 .  
  .  
  .  
  _Query_ _Q_
  
  The first line of the input contains two positive integers _N_ and _Q_ (1 ≤
  _N_ ≤ 1000, 1 ≤ _Q_ ≤ 1000). _N_ is the number of database entries, and Q is
  the number of queries.
  
  Each of the following N lines has three components: era name, era-based year
  number and the corresponding western year (1 ≤ _EraBasedYear_ _i_ ≤
  _WesternYear_ _i_ ≤ 109 ). Each of era names consist of at most 16 Roman
  alphabet characters. Then the last _Q_ lines of the input specifies queries (1
  ≤ _Query_ _i_ ≤ 109 ), each of which is a western year to compute era-based
  representation.
  
  The end of input is indicated by a line containing two zeros. This line is not
  part of any dataset and hence should not be processed.
  
  You can assume that all the western year in the input is positive integers,
  and that there is no two entries that share the same era name.
attempt: inputnum, outputnum = (int(n) for n in input().split(" "))
  data = {}
  while True:
      for i in range(inputnum):
          temp = input().split(" ")
          data[temp[0]] = [int(temp[2]) - int(temp[1]) + 1, int(temp[2])]
      for o in range(outputnum):
          targ = int(input())
          for k, v in data.items():
              if v[0] <= targ <= v[1]:
                  print(k + " " + str(targ - v[0] + 1))
                  break
          else:
              print("Unknown")
      inputnum, outputnum = (int(n) for n in input().split(" "))
      if inputnum == outputnum == 0:
          break
  
problem_description: A: Era Name
  
  As many of you know, we have two major calendar systems used in Japan today.
  One of them is Gregorian calendar which is widely used across the world. It is
  also known as “Western calendar” in Japan.
  
  The other calendar system is era-based calendar, or so-called “Japanese
  calendar.” This system comes from ancient Chinese systems. Recently in Japan
  it has been a common way to associate dates with the Emperors. In the era-
  based system, we represent a year with an era name given at the time a new
  Emperor assumes the throne. If the era name is “A”, the first regnal year will
  be “A 1”, the second year will be “A 2”, and so forth.
  
  Since we have two different calendar systems, it is often needed to convert
  the date in one calendar system to the other. In this problem, you are asked
  to write a program that converts western year to era-based year, given a
  database that contains association between several western years and era-based
  years.
  
  For the simplicity, you can assume the following:
  
    1. A new era always begins on January 1st of the corresponding Gregorian year.
    2. The first year of an era is described as 1.
    3. There is no year in which more than one era switch takes place.
  
  Please note that, however, the database you will see may be incomplete. In
  other words, some era that existed in the history may be missing from your
  data. So you will also have to detect the cases where you cannot determine
  exactly which era the given year belongs to.
samples: [{"input": "3\n    meiji 10 1877\n    taisho 6 1917\n    showa 62 1987\n    heisei 22 2010\n    1868\n    1917\n    1988\n    1 1\n    universalcentury 123 2168\n    2010\n    0 0", "output": "meiji 1\n    taisho 6\n    Unknown\n    Unknown"}]