Under construction

Still being built. Things may change

Electrician

Time limit2sMemory limit2048 MB

Summary
Given n houses and a limit k on how many times the villain's light may go off, find the fewest hours needed to identify the villain and restore every light.
Level

Medium7 of 10

Topics
Combinatorics, Binary search, Math
Solved
No attempts yet

Problem

There are nn houses with internet access in village J. One of them is home to a villain who keeps posting angry comments about us on social media from a fake account. We do not know which house it is, and we want to find out.

The electrical substation has nn switches, one for each house. When a switch is on, its house has light and internet access. When it is off, the house has no light and no internet. At the start, every switch is on. At the start of each hour, we can set the switches in any pattern we like, turning some on and some off. Then, during the following hour, we watch social media: if the villain's house has light, comments appear for sure, and if not, none appear. When the investigation ends, we must turn every light back on.

If the light in the villain's house goes out more than kk times, the villain becomes suspicious, and we want to avoid that. A light may stay off for a long time without cost. Only the number of times it is switched off counts. What is the minimum number of hours needed to identify the villain's house with certainty and restore the light in every house?

Input

The first line contains an integer tt, the number of test cases (1≤t≤2⋅1051 \le t \le 2 \cdot 10^5). Each of the next tt lines contains two integers nn and kk: the number of houses, and the maximum number of times we can switch the light off in the villain's house (1≤n,k≤10181 \leq n, k \leq 10^{18}).

Output

For each test case, print on one line the minimum number of hours needed to identify the villain's house and restore the light in every house.

Hint

In the first test case, n=3n = 3 and k=1k = 1. In the first hour, turn off the lights in houses 1 and 2. After an hour, turn the light back on in house 1, and after another hour, turn it back on in house 2. At the beginning of the third hour, we know for sure where the villain lives, and we restore the light in all houses.

Examples1

  1. Example 1

    Input
    5
    3 1
    4 1
    2 2
    17 3
    73 6
    
    Expected output
    2
    2
    1
    5
    7