#include <bits/stdc++.h>
using namespace std;
int main() {
  long long t;
  cin >> t;
  while (t--) {
    int k, n;
    cin >> n >> k;
    vector<pair<long long, long long> > m(n);
    map<pair<long long, long long>, long long> org;
    for (int i = 0; i < n; i++) {
      cin >> m[i].second >> m[i].first;
      org[m[i]] = i;
    }
    sort(m.begin(), m.end());
    vector<vector<long long> > dp(n + 1, vector<long long>(k + 1, 0));
    vector<vector<vector<long long> > > fr(
        n + 1, vector<vector<long long> >(k + 1, vector<long long>(n, -1)));
    for (int i = 1; i <= n; i++) {
      for (int j = 1; j <= min(k, i); j++) {
        if (dp[i - 1][j - 1] + m[i - 1].second + (j - 1) * m[i - 1].first >
            dp[i - 1][j] + (k - 1) * m[i - 1].first) {
          fr[i][j] = fr[i - 1][j - 1];
          fr[i][j][org[m[i - 1]]] = 1;
        } else {
          fr[i][j] = fr[i - 1][j];
          fr[i][j][org[m[i - 1]]] = 0;
        }
        dp[i][j] = max(dp[i][j], dp[i - 1][j - 1] + m[i - 1].second +
                                     (j - 1) * m[i - 1].first);
        dp[i][j] = max(dp[i][j], dp[i - 1][j] + (k - 1) * m[i - 1].first);
      }
    }
    vector<int> ber, ne;
    for (int i = 0; i < n; i++) {
      if (fr[n][k][org[m[i]]] == 1)
        ber.push_back(org[m[i]] + 1);
      else {
        ne.push_back(org[m[i]] + 1);
        ne.push_back(-org[m[i]] - 1);
      }
    }
    cout << ber.size() + ne.size() << endl;
    for (int i = 0; i < ber.size() - 1; i++) {
      cout << ber[i] << " ";
    }
    for (int i = 0; i < ne.size(); i++) {
      cout << ne[i] << " ";
    }
    cout << ber.back() << endl;
  }
  return 0;
}
