#include<bits/stdc++.h>

#define rep(i,n) for(int i=0;i<(int)n;i++)
#define all(c) (c).begin(),(c).end()
#define mp make_pair
#define pb push_back
#define each(i,c) for(__typeof((c).begin()) i=(c).begin();i!=(c).end();i++)
#define dbg(x) cerr<<__LINE__<<": "<<#x<<" = "<<(x)<<endl

using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef pair<int,int> pi;
const int inf = (int)1e9;
const double INF = 1e12, EPS = 1e-9;

ll dp[100][100];

int main(){
	//egg iter
	memset(dp, -1, sizeof(dp));
	rep(i, 100) rep(j, 100){
		if(i == 0) dp[i][j] = 1;
		if(j == 0) dp[i][j] = 1;
		if(dp[i][j] < 0) dp[i][j] = dp[i - 1][j - 1] + dp[i][j - 1];
	}
	int t; cin >> t;
	while(t--){
		ll n; int e; cin >> n >> e;
		for(int i = 0; ; i++){
			if(dp[e][i] > n){
				cout << i << endl;
				break;
			}
		}
	}
	
	return 0;
}