#include using namespace std; main() { int Q;cin>>Q; for(;Q--;) { int N,K; cin>>N>>K; if(K==1)cout<