#include <bits/stdc++.h>
using namespace std;
const long long INF = (long long)1e18;
const int mod = (int)1e9 + 7;
const int MAXN = (int)3e5 + 5;
pair<pair<int, int>, int> cr[MAXN];
int dp[80][80];
int pre[MAXN];
int par[80][80];
void solve() {
  int n, k;
  cin >> n >> k;
  for (int i = 1; i <= n; i++) {
    int a, b;
    cin >> a >> b;
    cr[i] = {{b, a}, i};
  }
  sort(cr + 1, cr + n + 1);
  for (int i = 1; i <= n; i++) {
    pre[i] = pre[i - 1] + cr[i].first.first;
  }
  memset(dp, 128, sizeof(dp));
  memset(par, -1, sizeof(par));
  dp[0][0] = 0;
  int ans = -mod;
  int lans = -mod;
  for (int i = 1; i <= n; i++) {
    for (int j = 1; j <= k; j++) {
      for (int l = 0; l < i; l++) {
        int deg = (pre[i - 1] - pre[l]) * (k - 1) + dp[l][j - 1] +
                  cr[i].first.first * (j - 1) + cr[i].first.second;
        if (deg > dp[i][j]) {
          dp[i][j] = deg;
          par[i][j] = l;
        }
      }
    }
    int deg = dp[i][k] + (pre[n] - pre[i]) * (k - 1);
    if (deg > ans) {
      ans = deg;
      lans = dp[i][k];
    }
  }
  vector<int> dis;
  vector<int> ic;
  cout << 2 * n - k << '\n';
  int cur = k;
  for (int i = n; i >= 1; i--) {
    if (dp[i][cur] == lans) {
      lans = dp[par[i][cur]][cur - 1];
      cur--;
      ic.push_back(cr[i].second);
    } else {
      dis.push_back(cr[i].second);
    }
  }
  reverse(ic.begin(), ic.end());
  for (int i = 0; i < (int)ic.size() - 1; i++) {
    cout << ic[i] << " ";
  }
  for (int i = 0; i < (int)dis.size(); i++) {
    cout << dis[i] << " " << -dis[i] << " ";
  }
  cout << ic.back() << '\n';
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);
  cout.tie(nullptr);
  int t;
  cin >> t;
  while (t--) solve();
}
