#include <bits/stdc++.h>
using namespace std;
const int inf = 1e09 + 5e3;
const long long linf = 2e18 + 5e3;
const int mxn = 1e5;
void solve() {
  int n, k;
  cin >> n >> k;
  vector<pair<int, int> > vp;
  int temp, temp2;
  long long total = 0;
  for (int i = 0; i < n; i++) {
    cin >> temp >> temp2;
    vp.emplace_back(temp, temp2);
    total += temp2 * (k - 1);
  }
  set<int> na;
  vector<int> out;
  for (int i = 0; i < k; i++) {
    long long best = -linf, pos = -1;
    for (int j = 0; j < n; j++) {
      if (na.count(j)) continue;
      if ((vp[j].first - vp[j].second * i) > best) {
        best = (vp[j].first - vp[j].second * i);
        pos = j;
      }
    }
    total += best;
    na.insert(pos);
    out.push_back(pos);
  }
  sort((out).begin(), (out).end(), [vp](const int &lhs, const int &rhs) {
    return vp[lhs].second < vp[rhs].second;
  });
  cout << 2 * n - k << '\n';
  for (int i = 0; i < (int)out.size() - 1; i++) {
    cout << out[i] + 1 << ' ';
  }
  for (int i = 0; i < n; i++) {
    if (!na.count(i)) cout << i + 1 << ' ' << -i - 1 << ' ';
  }
  cout << out.back() + 1;
  cout << '\n';
}
int main() {
  ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
  int t;
  cin >> t;
  while (t--) {
    solve();
  }
}
