#include <bits/stdc++.h>
using namespace std;
constexpr long long N = 80 + 9;
constexpr long long M = 1e4 + 9;
constexpr long long INF = 0x3f3f3f3f3f3f3f3f;
constexpr long long INF2 = 0xcfcfcfcfcfcfcfcf;
long long t, n, k;
long long a[N], b[N];
long long id[N];
long long dp[N][N];
long long from[N][N];
signed main() {
  ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
  ;
  cin >> t;
  while (t--) {
    cin >> n >> k;
    for (long long i = 1; i <= n; i++) {
      cin >> a[i] >> b[i];
      id[i] = i;
    }
    sort(id + 1, id + n + 1,
         [](const long long& i, const long long& j) { return b[i] < b[j]; });
    memset(dp, 0xcf, sizeof(dp));
    dp[0][0] = 0;
    for (long long i = 0; i < n; i++) {
      for (long long j = 0; j <= i && j <= k; j++) {
        if (j < k && dp[i][j] + a[id[i + 1]] + (k - 1) * b[id[i + 1]] >
                         dp[i + 1][j + 1]) {
          dp[i + 1][j + 1] = dp[i][j] + a[id[i + 1]] + (k - 1) * b[id[i + 1]];
          from[i + 1][j + 1] = 0;
        }
        if (dp[i][j] + b[id[i + 1]] * (k - 1) > dp[i + 1][j]) {
          dp[i + 1][j] = dp[i][j] + b[id[i + 1]] * (k - 1);
          from[i + 1][j] = 1;
        }
      }
    }
    vector<long long> add, del;
    while (n) {
      if (from[n][k]) {
        del.push_back(id[n]);
      } else {
        add.push_back(id[n]);
        k--;
      }
      n--;
    }
    cout << add.size() + del.size() * 2 << endl;
    for (long long j = 0; j < add.size() - 1; j++) {
      cout << add[j] << " ";
    }
    for (long long j : del) {
      cout << j << " " << -j << " ";
    }
    cout << add.back() << endl;
  }
  return 0;
}
