#include <bits/stdc++.h>
using namespace std;
int main(){
int T=0;
cin>>T;
while(1){
int n,k;
cin>>n>>k;
if(k==1){
cout<<n<<"\n";
}else{
int sum=0;
for(int i=1;;i+=(k-1)){
sum+=i;
if(sum>=n){
cout<<i<<"\n";
}
}
}
}
return 0;
}
To embed this project on your website, copy the following code and paste it into your website's HTML: