#include <bits/stdc++.h>
#define ld long double
#define endl "\n"
#define fastio ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define pb(x) push_back(x)
#define mp(a,b) make_pair(a,b)
#define ms(v,x) memset(v,x,sizeof(v))
#define all(v) v.begin(),v.end()
#define ff first
#define ss second
#define rep(i, a, b) for(int i = a; i < (b); ++i)
//#define per(i, a, b) for(int i = b-1; i>=a ; i--)
#define trav(a, x) for(auto& a : x)
#define allin(a , x) for(auto a : x)
#define td(v) v.begin(),v.end()
#define sz(v) (int)v.size()
//#define M   1000000007 // 1e9 + 7
#define int long long
using namespace std;
typedef vector<int> vi;
typedef long long ll;
typedef pair<int,int> pii;

inline ll mod(ll n, ll m ){ ll ret = n%m; if(ret < 0) ret += m; return ret; }
ll gcd(ll a, ll b){return (b == 0LL ? a : gcd(b, a%b));}

ll exp(ll a,ll b,ll m){
    if(b==0LL) return 1LL;
    if(b==1LL) return mod(a,m);
    ll k = mod(exp(a,b/2,m),m);
    if(b&1LL){
        return mod(a*mod(k*k,m),m);
    }
    else return mod(k*k,m);
}
const int N = 80;

struct coisa{
  int a,b,id;
  coisa(){}

  coisa(int A,int B,int C){
    a = A,b=B,id=C;
  }
}v[N];

int dp[N][N];
void solve(){
  int n,k;
  cin>>n>>k;
  for(int i=1;i<=n;i++){
    int a,b;
    cin>>a>>b;
    v[i] = coisa(a,b,i);
  }
  sort(v+1,v+1+n,[&](coisa a,coisa b){
    return a.b < b.b;
  });

  if(k==1){
    sort(v+1,v+1+n,[&](coisa a,coisa b){
      return a.a > b.a;
    });
    cout << 1 << endl;
    cout << v[1].id << endl;
    return;
  }

  if(k==n){

    cout << n << endl;
    for(int i=1;i<=n;i++){
      cout << v[i].id<<" ";
    }
    cout << endl;
    return;
  }
  rep(i,0,N)rep(j,0,N)dp[i][j] = -1e9;
  dp[0][0] = 0;
  for(int i=1;i<=n;i++){

    for(int j=0;j<=min(i-1,k);j++){
      // pega ou nao
      dp[i][j+1] = max(dp[i][j+1],dp[i-1][j] + j*v[i].b + v[i].a);
      // nao pega
      dp[i][j]  = max(dp[i][j],dp[i-1][j] + (k-1)*v[i].b);
    }

  }

  vector<int> tira,col;
  int j = k;

  for(int i=n;i>=1;i--){
    if(i==1){
      if(j==0)tira.pb(i);
      else {col.pb(i);j--;}
      break;
    }
    if(j==0)tira.pb(i);
    else{

      if(dp[i][j] == dp[i-1][j-1] + (j-1)*v[i-1].b + v[i].a){
        col.pb(i);
        j--;
      }else{
        tira.pb(i);
      }

    }
  }

  reverse(col.begin(),col.end());
  vector<int> ans;

  for(int i=0;i<sz(col) - 1;i++)ans.pb(v[col[i]].id);
  for(int x : tira)ans.pb(v[x].id),ans.pb(-v[x].id);
    ans.pb(v[col[sz(col)-1]].id);  
  cout << ans.size() << endl;
  for(int x : ans )cout << x<<" ";
    cout << endl;
}
int32_t main(){
  fastio;
  
  int t;
  cin>>t;
  while(t--){
    solve();
  }


  // Math -> gcd it all
  // Did u check N=1? Did you switch N,M?
}