#include <bits/stdc++.h>
using namespace std;
long long dp[76][76];
long long col[76][76];
vector<pair<pair<int, int>, int> > v;
bool sortf(const pair<pair<int, int>, int> &a,
           const pair<pair<int, int>, int> &b) {
  return a.first.second < b.first.second;
}
int main() {
  int t;
  cin >> t;
  for (int num_tests = 0; num_tests < t; ++num_tests) {
    int n, k;
    cin >> n >> k;
    v.clear();
    for (int i = 0; i < n; ++i) {
      int a, b;
      cin >> a >> b;
      v.push_back(make_pair(make_pair(a, b), i + 1));
    }
    sort(v.begin(), v.end(), sortf);
    for (int i = 0; i < n; ++i) {
      for (int j = 0; j < n; j++) {
        dp[i][j] = 0;
        col[i][j] = 0;
      }
    }
    dp[0][0] = (k - 1) * v[0].first.second;
    dp[0][1] = v[0].first.first;
    for (int i = 1; i < n; ++i) {
      dp[i][0] = dp[i - 1][0] + v[i].first.second;
      col[i][0] = 2;
      for (int j = 1; j < i + 1; j++) {
        long long tmp1 = dp[i - 1][j] + (k - 1) * v[i].first.second;
        long long tmp2 =
            dp[i - 1][j - 1] + v[i].first.first + (j - 1) * v[i].first.second;
        if (tmp1 > tmp2) {
          dp[i][j] = tmp1;
          col[i][j] = 2;
        } else {
          dp[i][j] = tmp2;
          col[i][j] = 1;
        }
      }
      dp[i][i + 1] = dp[i - 1][i] + v[i].first.first + (i)*v[i].first.second;
      col[i][i + 1] = 1;
    }
    vector<int> group1;
    vector<int> group2;
    int i2 = k;
    for (int i = n - 1; i >= 0; i--) {
      if (col[i][i2] == 2) {
        group2.push_back(v[i].second);
      } else {
        group1.push_back(v[i].second);
        i2--;
      }
    }
    reverse(group1.begin(), group1.end());
    cout << 2 * n - k << endl;
    if (group1.size() != k) {
      cout << "why??" << endl;
    }
    for (int i = 0; i < group1.size() - 1; i++) {
      cout << group1[i] << endl;
    }
    for (int i = 0; i < group2.size(); ++i) {
      cout << group2[i] << endl;
      cout << -group2[i] << endl;
    }
    cout << group1[k - 1] << endl;
  }
}
