#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define int ll
#define ull unsigned long long
#define pii pair<int,int>
#define X first
#define Y second
#define mod ((ll)1e9+7)
#define pb push_back
#define mp make_pair
#define abs(x) ((x)>0?(x):(-(x)))
#define F(n) Fi(i,n)
#define Fi(i,n) Fl(i,0,n)
#define Fl(i,l,n) for(int i=l;i<n;i++)
#define memres(a) memset(a,0,sizeof(a))
#define all(a) a.begin(),a.end()
#define sz(a) ((int)a.size())
#define ceiling(a,b) (((a)+(b)-1)/(b))
#define endl '\n'
//#define LOCAL
#ifdef LOCAL
#define debug(a) cerr<<#a<<" "<<a<<endl;
#else
#define debug(a)
#endif
int gcd(int a,int b){if(b==0)return a;return gcd(b,a%b);}
pii ar[75];
bool cmp(int a,int b){return ar[a].Y<ar[b].Y;}
signed main(){
	ios_base::sync_with_stdio(0);cin.tie(0);
	int t;
	cin>>t;
	while(t--){
		int n,k;
		cin>>n>>k;
		F(n)cin>>ar[i].X>>ar[i].Y;
		pii dp[76][76];
		F(n+1)Fi(j,k+1)dp[i][j]={-1,-1};
		dp[0][0]={0,0};
		F(n){
			Fi(j,k){
				if(dp[i][j].X!=-1){
					if(dp[i+1][j+1].X<dp[i][j].X+ar[i].X+ar[i].Y*i)dp[i+1][j+1]={dp[i][j].X+ar[i].X+ar[i].Y*i,i+1};
					if(dp[i+1][j].X<dp[i][j].X+ar[i].Y*(k-1))dp[i+1][j]={dp[i][j].X+ar[i].Y*(k-1),dp[i][j].Y};
				}
			}
				}
		int p=dp[n][k].Y,c=k;
		vector<int> v;
		bool us[n+1]={false};
		while(p&&c){
			v.pb(p);
			us[p]=true;
			p=dp[p-1][--c].Y;
		}
		cout<<n*2-k<<endl;
		sort(all(v),cmp);
		F(sz(v)-1)cout<<v[i]<<" ";
		for(int i=1;i<=n;i++)if(!us[i])cout<<i<<" "<<-i<<" ";
		cout<<v[(sz(v)-1)]<<endl;
	}
return 0;
}

