#include <bits/stdc++.h>
using namespace std;
const long long inf = 0x3f3f3f3f3f3f3f3f;
const int N = 80;
int id[N], a[N], b[N];
int res[N][N];
long long dp[N][N];
bool cmp(int x, int y) { return b[x] < b[y]; }
void solve() {
  int n, k;
  cin >> n >> k;
  for (int i = 1; i <= n; i++) cin >> a[i] >> b[i], id[i] = i;
  sort(id + 1, id + 1 + n, cmp);
  for (int i = 0; i <= n; i++)
    for (int j = 0; j <= i; j++) dp[i][j] = -inf, res[i][j] = 0;
  dp[0][0] = 0;
  for (int i = 0; i < n; i++)
    for (int j = 0; j <= i; j++) {
      if (dp[i][j] >= 0) {
        long long w = dp[i][j] + j * b[id[i + 1]] + a[id[i + 1]];
        if (w > dp[i + 1][j + 1]) {
          dp[i + 1][j + 1] = w;
          res[i + 1][j + 1] = id[i + 1];
        }
        w = dp[i][j] + (k - 1) * b[id[i + 1]];
        if (w > dp[i + 1][j]) {
          dp[i + 1][j] = w;
          res[i + 1][j] = -id[i + 1];
        }
      }
    }
  vector<int> A, B, ans;
  for (int i = n; i; i--) {
    if (res[i][k] > 0) {
      A.push_back(res[i][k]);
      --k;
    } else {
      B.push_back(-res[i][k]);
    }
  }
  reverse(B.begin(), B.end());
  for (int i = 0; i < (int)A.size() - 1; i++) ans.push_back(A[i]);
  for (auto it : B) {
    ans.push_back(it);
    ans.push_back(-it);
  }
  ans.push_back(A.back());
  cout << (int)ans.size() << '\n';
  for (auto it : ans) cout << it << ' ';
  cout << '\n';
}
int main() {
  std::ios::sync_with_stdio(false), cin.tie(0), cout.tie(0);
  int _;
  cin >> _;
  while (_--) solve();
  return 0;
}
