Segment Tree
题号:NC237296
时间限制:C/C++/Rust/Pascal 2秒,其他语言4秒
空间限制:C/C++/Rust/Pascal 256 M,其他语言512 M
64bit IO Format: %lld

题目描述

Once upon a time, there was a segment tree of size .

You need to insert  times in this segment tree.

Construct the array  so that the value of cnt is maximum cnt after finishing all the operations.

输入描述:

The first line contains a single integer   - the number of test cases.

For each next  line, it contains two positive integers   - the size of the segment tree and the number of operations.

输出描述:

For each test case, output a single integer represents the answer - the maximum cnt you can get.
示例1

输入

复制
5
3 2
4 1
18 7
262144 65536
200000000 2262300

输出

复制
4
3
23
262143
20030403