#include <bits/stdc++.h>
using namespace std;
int N, K, T;
pair<pair<long long, long long>, int> arr[80];
long long dp[80][80];
int sol[80][80];
vector<int> s1, s2;
void rellenar() {
  s1.clear();
  s2.clear();
  for (int i = 0; i < 80; i++) {
    for (int j = 0; j < 80; j++) {
      dp[i][j] = -(1ll << 60);
      sol[i][j] = 0;
    }
  }
  dp[0][0] = 0;
}
bool compa(const pair<pair<long long, long long>, int> &A,
           const pair<pair<long long, long long>, int> &B) {
  if (A.first.first == B.first.first) return A.first.second > B.first.second;
  return A.first.first < B.first.first;
}
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  cin >> T;
  while (T--) {
    cin >> N >> K;
    for (int i = 1; i <= N; i++) {
      cin >> arr[i].first.second >> arr[i].first.first;
      arr[i].second = i;
    }
    sort(arr + 1, arr + (N + 1), compa);
    rellenar();
    for (int i = 1; i <= N; i++)
      for (int j = 0; j <= K; j++) {
        if (dp[i - 1][j] >= 0 &&
            dp[i][j] < dp[i - 1][j] + arr[i].first.first * long long(K - 1)) {
          dp[i][j] = dp[i - 1][j] + arr[i].first.first * long long(j - 1);
          sol[i][j] = 2;
        }
        if (j && dp[i - 1][j - 1] >= 0 &&
            dp[i][j] < dp[i - 1][j - 1] +
                           arr[i].first.first * long long(j - 1) +
                           arr[i].first.second) {
          dp[i][j] = dp[i - 1][j - 1] + arr[i].first.first * long long(j - 1) +
                     arr[i].first.second;
          sol[i][j] = 1;
        }
      }
    int k = K;
    for (int i = N; i > 0; i--)
      if (sol[i][k] == 1) {
        s1.push_back(arr[i].second);
        k--;
      } else
        s2.push_back(arr[i].second);
    reverse(s1.begin(), s1.end());
    reverse(s2.begin(), s2.end());
    cout << K + 2 * (N - K) << "\n";
    for (int i = 0; i < K - 1; i++) cout << s1[i] << " ";
    for (auto &v : s2) cout << v << " " << -v << " ";
    cout << s1[K - 1] << "\n";
  }
  return 0;
}
