单点时限: 5.0 sec
内存限制: 512 MB
lbromine
,Komorebi
andAmuzi
like to play hide-and-seek in the teaching building. The teaching building is very large and its structure is very strange. It is composed of
lbromine
is responsible for finding and Komorebi
andAmuzi
are responsible for hiding.But the teaching building is too big, solbromine
makes a rule that the Komorebi
andAmuzi
can only hide in the classroom with the classroom number in the range of
At the beginning,lbromine
can use his transmission device to transmit to any classroom in the teaching building with Komorebi
and Amuzi
along the passages of the classrooms. In order to evaluate whether the selected interval lbromine
wants to know the shortest possible time he needs to find Komorebi
and Amuzi
for some intervals.
The first line of input contains a positive integer
The next lbromine
needs
An integer
The next
For each query output one line contains one integer indicating the shortest possible time for him to find Komorebi
and Amuzi
.
5 1 5 1 5 4 2 2 4 3 3 4 4 3 1 3 3 5 2 3
6 2 7
The structure of the teaching building in the sample is as follows
So for the interval Komorebi
hides in classroom Amuzi
hides in classroom lbromine
can transmit to classroom lbromine
to find Komorebi
and Amuzi
.