Suspects
In a police investigation, suspects were identified and now it’s up to the witnesses to try to find the perpetrator. The height of every suspect was measured, but due to the unreliability of measurement, it is known only that their height is a real number from the interval from to (inclusive). At most one of the suspects is the perpetrator, and it could be the case that none of them are.
A signle lineup consists of choosing two positive integers and , then taking the suspects to a separate room so that the witnesses could try to identify the perpetrator. As the witnesses could be confused if two of the suspects have the same height, a lineup is allowed only if it is possible to guarantee that no two suspects will have the same height. During a lineup, the witnesses will always be able to identify the perpetrator if he is among the chosen suspects, or they will be able to tell that he is not among them.
The lead investigator is now interested in answering questions of the following form: “If I were certain that the label of the perpetrator could only be between and , what is the minimum number of lineups needed in the worst case so that the witnesses are able to find the perpetrator, or report that he is not among the suspects?” Help the lead investigator answer of such questions.
Input
The first line contains a positive integer , the number of suspects. The following lines contain two positive integers and which represent the possible height range of the suspect with label .
The next line contains a positive integer , the number of questions. The following lines contain two positive integers and which determine a question.
Output
In lines print the answers to the corresponding questions: the minimum required number of lineups.