#include <bits/stdc++.h>
using namespace std;
mt19937 __MT(chrono::system_clock::now().time_since_epoch().count());
const int maxn = 75 + 10;
long long a[maxn];
long long b[maxn];
int n, k;
long long sumb;
inline void rel_strategy(int mz) {
  priority_queue<pair<pair<long long, long long>, long long>,
                 vector<pair<pair<long long, long long>, long long>>,
                 less<pair<pair<long long, long long>, long long>>>
      q;
  for (auto j = (1); j <= (n); ++j) {
    if (mz == j) continue;
    q.push({{a[j], -b[j]}, j});
  }
  vector<pair<pair<long long, long long>, long long>> c;
  vector<int> lt;
  vector<int> ans;
  long long tmpb = sumb;
  long long suma = 0;
  for (auto j = (0); j < (k - 1); ++j) {
    auto e = q.top();
    q.pop();
    e.first.second *= -1;
    swap(e.first.second, e.first.first);
    c.push_back(e);
    tmpb -= e.first.first;
  }
  while (!q.empty()) {
    lt.push_back(q.top().second);
    q.pop();
  }
  sort((c).begin(), (c).end());
  int has = 0;
  for (auto e : c) {
    suma += e.first.second;
    suma += e.first.first * has;
    has++;
    ans.push_back(e.second);
  }
  for (auto e : lt) {
    ans.push_back(e), ans.push_back(-e);
  }
  ans.push_back(mz);
  suma += tmpb * (k - 1);
  suma += a[mz];
  printf("%d\n", (int)ans.size());
  for (auto e : ans) {
    printf("%d ", e);
  }
  puts("");
}
inline void solve() {
  long long ans = -1;
  int mz;
  for (auto i = (1); i <= (n); ++i) {
    priority_queue<pair<pair<long long, long long>, long long>,
                   vector<pair<pair<long long, long long>, long long>>,
                   less<pair<pair<long long, long long>, long long>>>
        q;
    for (auto j = (1); j <= (n); ++j) {
      if (i == j) continue;
      q.push({{a[j], -b[j]}, j});
    }
    vector<pair<pair<long long, long long>, long long>> c;
    long long tmpb = sumb;
    long long suma = 0;
    for (auto j = (0); j < (k - 1); ++j) {
      auto e = q.top();
      q.pop();
      e.first.second *= -1;
      swap(e.first.second, e.first.first);
      c.push_back(e);
      tmpb -= e.first.first;
    }
    sort((c).begin(), (c).end());
    int has = 0;
    for (auto e : c) {
      suma += e.first.second;
      suma += e.first.first * has;
      has++;
    }
    suma += tmpb * (k - 1);
    suma += a[i];
    if (suma > ans) {
      ans = suma;
      mz = i;
    }
  }
  rel_strategy(mz);
}
int main(void) {
  int T;
  scanf("%d", &(T));
  for (; T--;) {
    scanf("%d", &(n)), scanf("%d", &(k));
    sumb = 0;
    for (auto i = (1); i <= (n); ++i)
      scanf("%lld", &(a[i])), scanf("%lld", &(b[i])), sumb += b[i];
    solve();
  }
  return 0;
}
