#include <bits/stdc++.h>
using namespace std;
array<long long, 3> arr[80];
long long dp[80][80];
long long use[80][80];
int main() {
  int T;
  cin >> T;
  for (int i = 0; i < T; ++i) {
    int N, K;
    cin >> N >> K;
    for (int j = 0; j < N; ++j) {
      cin >> arr[j][1] >> arr[j][0];
      arr[j][2] = j + 1;
    }
    memset(dp, 0, sizeof(dp));
    memset(use, -1, sizeof(use));
    sort(arr, arr + N);
    for (int j = 1; j <= N; ++j) {
      for (int k = 1; k <= K; ++k) {
        if (k > j) {
          dp[j][k] = -999999999999;
          use[j][k] = -1;
          continue;
        }
        dp[j][k] =
            max(dp[j - 1][k - 1] + arr[j - 1][0] * (k - 1) + arr[j - 1][1],
                dp[j - 1][k] + (K - 1) * arr[j - 1][0]);
        if (dp[j - 1][k - 1] + arr[j - 1][0] * (k - 1) + arr[j - 1][1] >=
            dp[j - 1][k] + (K - 1) * arr[j - 1][0]) {
          use[j][k] = arr[j - 1][2];
        } else {
          use[j][k] = -1;
        }
      }
    }
    int keepTrack = K;
    vector<int> usin;
    set<int> used;
    for (int j = N; j >= 1; --j) {
      if (use[j][keepTrack] != -1) {
        usin.push_back(use[j][keepTrack]);
        used.insert(use[j][keepTrack]);
        keepTrack--;
      }
    }
    cout << 2 * N - K << endl;
    for (int j = 0; j < K - 1; ++j) {
      cout << usin[K - 1 - j] << " ";
    }
    for (int j = 1; j <= N; ++j) {
      if (used.find(j) == used.end()) {
        cout << j << " " << -j << " ";
      }
    }
    cout << usin[0] << endl;
  }
}
