Malvika conducts a Programming Camp
Time limit1sMemory limit1024 MB
Find the minimum hours for n people in a line to learn m topics, where Malvika at the end teaches and each hour one neighbour teaches another.
Statement
Malvika has gained a lot of knowledge from programming contests. She wants to use it to train the next generation of Indian programmers, so she holds a programming camp. There are people in a discussion session: students and Malvika herself. They sit in a line from left to right, numbered 1 to . Malvika sits in spot . She wants to teach topics of competitive programming to the students. All the participants are newbies. At the start, the first people know none of the topics, and the th person (Malvika) knows all of them.
It takes one hour for a person to learn a topic from a neighbour. One person cannot teach and learn during the same hour. In any hour, a person can either teach a topic he knows to one of his neighbours, learn a topic from one of his neighbours, or sit idle. If person is learning from person in some hour, then person must be teaching person in that same hour. People can work in parallel. For example, while the 4th person teaches the 3rd person, the 1st person can teach the 2nd person or learn from the 2nd person.
Find the minimum number of hours needed for every person to learn all topics.
Input
The first line contains a single integer , the number of test cases. Each test case is one line with two space-separated integers and , as defined in the statement.
Output
For each test case, print a single integer on its own line: the answer to the problem.
Constraints
Hint
In the first example there are two people. The second person is Malvika and she has to teach only one topic to the first person. This takes one hour.
In the second example there are three people. The 3rd person is Malvika and she has to teach two topics to the 1st and 2nd persons. In the 1st hour, she teaches the 1st topic to the 2nd person. In the 2nd hour, the 2nd person teaches the 1st topic to the 1st person. In the 3rd hour, Malvika teaches the 2nd topic to the 2nd person. In the 4th hour, the 2nd person teaches that topic to the 1st person. So the total is 4 hours.