#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef complex<double> P;
#define REP(i,n) for(int i=0;i<n;++i)
#define REPR(i,n) for(int i=1;i<n;++i)

#define DEBUG(x) cout<<#x<<": "<<x<<endl
#define DEBUG_VEC(v) REP(i,v.size())cout<<#v<<"["<<i<<"]: "<<v[i]<<endl
#define ALL(a) (a).begin(),(a).end()

ll eggdrops[51][51];

int main(){
  // https://oeis.org/A180975
  REP(i,51)REP(j,51){
    if(i==0||j==0)eggdrops[i][j]=0;
    else eggdrops[i][j]=eggdrops[i-1][j-1]+1+eggdrops[i-1][j];
  }

  int T;
  cin >> T;
  REP(_t,T){
    ll N,E;
    cin >> N >> E;
    REP(n,51){
      ll w = eggdrops[n][E];
      if(N<=w){
        cout << n << endl;
        break;
      }
    }
  }
  return 0;
}