#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> // Common file
#include <ext/pb_ds/tree_policy.hpp> // Including tree_order_statistics_node_update

using namespace std;
using namespace __gnu_pbds;
//typedef tree<
//        pair<long long, int>, // change type
//        null_type,
//        less<pair<long long, int> >, // change type
//        rb_tree_tag,
//        tree_order_statistics_node_update>
//        ordered_set;

template<class T> using ordered_set = tree<T, null_type, less<T>, rb_tree_tag,tree_order_statistics_node_update>;


vector<string> vec_splitter(string s) {
    s += ',';
    vector<string> res;
    while(!s.empty()) {
        res.push_back(s.substr(0, s.find(',')));
        s = s.substr(s.find(',') + 1);
    }
    return res;
}
void debug_out(
        vector<string> __attribute__ ((unused)) args,
        __attribute__ ((unused)) int idx,
        __attribute__ ((unused)) int LINE_NUM) { cerr << endl; }
template <typename Head, typename... Tail>
void debug_out(vector<string> args, int idx, int LINE_NUM, Head H, Tail... T) {
    if(idx > 0) cerr << ", "; else cerr << "Line(" << LINE_NUM << ") ";
    stringstream ss; ss << H;
    cerr << args[idx] << " = " << ss.str();
    debug_out(args, idx + 1, LINE_NUM, T...);
}
#define debug(...) debug_out(vec_splitter(#__VA_ARGS__), 0, __LINE__, __VA_ARGS__)

typedef long long ll;
#define rep(i, start, end) for(int i = start; i < end; ++i)
#define sz(x) (int)((x).size())
#define pb push_back
#define X first
#define Y second
#define all(x) x.begin(), x.end()
#define clr(d, v) memset(d, v, sizeof(d))
#define pii pair<int, int>
//#define debug(x) cerr << #x << " : " << (x) << " "
const double PI = 3.14159265358979323846;
const double eps = (1e-10);
int isGreater(long double x, long double y)
{
    if (abs(x - y) < eps)
        return 0;
    if (x > y)
        return 1;
    return -1;
}

const int N = 80;
struct S{
  int a, b, idx;
  bool operator<(const S& other) const{
    return b < other.b;
  }
};
S v[N];
int n, k;
vector<int> o, d;
int lst;
ll mem[N][N][2];
ll solve(int i, int c, int l)
{
  if (i == n){
    if (c == k - 1 && l)
      return 0;
    return -1e17;
  }
  ll &ret = mem[i][c][l];
  if (ret != -1)
    return -1;
    
  ret = solve(i +1, c, l) + (k - 1) * v[i].b;
  if (c < k - 1)
    ret = max(ret, solve(i + 1, c + 1, l) + v[i].a + c * v[i].b);
  if (!l)
    ret = max(ret, solve(i + 1, c, true) + v[i].a + v[i].b * (k - 1));
    
  return ret;
}


void build(int i, int c, int l)
{
  if (i == n){
    return;
  }
  ll &ret = mem[i][c][l];
    
  if (ret == solve(i +1, c, l) + (k - 1) * v[i].b)
  {
    d.pb(v[i].idx);
    build(i + 1, c, l);
    return;
  }
  if (c < k - 1)
  {
    if (ret == solve(i + 1, c + 1, l) + v[i].a + c * v[i].b){
      o.pb(v[i].idx);
      build(i + 1, c + 1, l);
      return;    
      }
    
   }
   lst = v[i].idx;
   build(i + 1, c, true);
}

void SOLVE(){
  cin >> n >> k;
  rep(i,0,n){
    cin >> v[i].a >> v[i].b;
    v[i].idx = i;
  }
  sort(v, v + n);
  clr(mem, -1);
  d.clear();
  o.clear();
  solve(0, 0, 0);
  build(0 ,0 , 0);
  cout << sz(o) + sz(d) * 2 + 1 << '\n';
  for (int item : o)
     cout << item << " ";
  for (int item : d)
      cout << item << " " << -item << " ";
  cout << lst << '\n';
}

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
//    freopen("AC.txt", "w", stdout);
#endif
    int tc;
    cin >> tc;
    while(tc--)
        SOLVE();
    
    return 0;
}