#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  int T;
  cin >> T;
  while (T--) {
    int N, K;
    cin >> N >> K;
    vector<pair<int, pair<int, int>>> V(N);
    int a, b;
    for (int i = 0; i < N; i++) {
      cin >> a >> b;
      V[i] = {b, {-a, i}};
    }
    sort(V.begin(), V.end());
    long long maxv = 0;
    vector<int> ans;
    for (int i = 0; i < N; i++) {
      vector<vector<long long>> dp(N, vector<long long>(K, -1));
      vector<vector<int>> rev(N, vector<int>(K, -1));
      vector<vector<int>> par(N, vector<int>(K, -1));
      for (int i = 0; i < N; i++) dp[i][0] = 0;
      int ti = 0;
      for (int j = 0; j < N; j++) {
        auto t = V[j];
        if (j == i) continue;
        for (int k = 0; k < K; k++) {
          if (dp[ti][k] < 0) continue;
          long long temp = dp[ti][k] + t.first * (K - 1);
          if (dp[ti + 1][k] < 0 || dp[ti + 1][k] < temp)
            dp[ti + 1][k] = temp, rev[ti + 1][k] = -t.second.second - 1,
                    par[ti + 1][k] = k;
          if (k + 1 < K) {
            temp = dp[ti][k] - t.second.first + t.first * k;
            if (dp[ti + 1][k + 1] < 0 || dp[ti + 1][k + 1] < temp)
              dp[ti + 1][k + 1] = temp,
                             rev[ti + 1][k + 1] = t.second.second + 1,
                             par[ti + 1][k + 1] = k;
          }
        }
        ti++;
      }
      vector<int> tans;
      vector<int> sub;
      int j = K - 1;
      ti = N - 1;
      while (ti >= 0) {
        int t = rev[ti][j];
        if (t < 0)
          sub.push_back(-t);
        else
          tans.push_back(t);
        j = par[ti][j];
        if (j <= 0) break;
        --ti;
      }
      long long v = dp[N - 1][K - 1] + V[i].first * (K - 1) - V[i].second.first;
      if (v > maxv) {
        maxv = v;
        reverse(tans.begin(), tans.end());
        for (auto &i : sub) tans.push_back(i), tans.push_back(-i);
        tans.push_back(V[i].second.second + 1);
        ans = tans;
      }
    }
    cout << ans.size() << "\n";
    for (auto &i : ans) cout << i << " ";
    cout << endl;
  }
}
