Unlike other BCD contests, this contest awards points for each problem and imposes a five-minute time penalty for each incorrect submission. Please keep this in mind before proceeding.
Each of the nations scattered over the different parts of the world has a special era.\
- Al-Biruni, The Chronology of Ancient Nations, Chapter III
You are organizing old documents. In the country where they were written, dates were recorded using era names rather than Common Era years.
In actual history, an era can begin partway through a year. In this problem, however, ignore its actual starting month and day: every era is assumed to begin on January of its given starting year.
The year in which an era begins is year of that era. Its year number increases by whenever the calendar year changes. When a new era begins, it replaces the previous era starting that year. The last era continues to be used thereafter.
You are given the names of the eras used in this country and the Common Era year in which each began. If a document was written in Common Era year , find its era name and year number within that era.
The first line contains the number of eras .
Each of the next lines contains an era name and its starting Common Era year , separated by a space. The eras are given in increasing order of their starting years, and no two eras begin in the same year.
Print the era name and year number used in the year the document was written, separated by a space.
In the first example, Common Era year is year of HEISEI, so Common Era year is year of HEISEI.
In the second example, the new era QIANLONG begins in Common Era year , so this is year of .
The last line contains the document's Common Era year .
QIANLONG