#include <bits/stdc++.h>
using namespace std;
long long int const mod = 998244353;
std::mt19937 rng(
    (int)std::chrono::steady_clock::now().time_since_epoch().count());
int rand_rng(int l, int r) {
  uniform_int_distribution<int> p(l, r);
  return p(rng);
}
long long int arr1[1000009];
vector<long long int> sieve;
void sievefun(long long int n) {
  for (long long int i = 2; i <= n; i++) {
    if (arr1[i] == 0) {
      for (long long int j = i * i; j <= n; j += i) {
        arr1[j] = 1;
      }
    }
  }
  for (int i = 2; i <= n; i++) {
    if (arr1[i] == 0) sieve.push_back(i);
  }
}
long long int power(long long int x, long long int y, long long int m) {
  long long int temp;
  if (y == 0 || x == 1) return 1;
  temp = power(x, y / 2, m) % m;
  if (y % 2 == 0)
    return ((temp) * (temp)) % m;
  else
    return (((x) % m) * ((temp * temp) % m)) % m;
}
long long int dp[109][109];
pair<pair<long long int, long long int>, int> a[109];
long long int p[109][109];
int main() {
  long long int T;
  cin >> T;
  for (int _ = 0; _ < (int)T; _++) {
    long long int n, k;
    cin >> n >> k;
    for (int i = 0; i < (int)n; i++) {
      cin >> a[i + 1].first.second >> a[i + 1].first.first;
      a[i + 1].second = i + 1;
    }
    sort(a + 1, a + n + 1);
    dp[0][0] = 0;
    for (int i = 0; i < (int)n + 1; i++)
      for (int j = 0; j < (int)k + 1; j++) dp[i][j] = -1, p[i][j] = 0;
    dp[0][0] = 0;
    for (int i = 1; i <= n; i++) {
      for (int j = 0; j <= k; j++) {
        if (dp[i - 1][j] != -1)
          dp[i][j] = dp[i - 1][j] + (k - 1) * a[i].first.first;
        if (j) {
          if (dp[i - 1][j - 1] != -1) {
            if (dp[i - 1][j - 1] + a[i].first.second +
                    a[i].first.first * (j - 1) >
                dp[i][j])
              p[i][j] = 1;
            dp[i][j] = max(dp[i][j], dp[i - 1][j - 1] + a[i].first.second +
                                         a[i].first.first * (j - 1));
          }
        }
      }
    }
    set<long long int> ans;
    int ind = n;
    int pos = k;
    vector<long long int> out;
    while (ind) {
      if (p[ind][pos]) {
        ans.insert(a[ind].second);
        pos--;
      }
      ind--;
    }
    ind = *ans.rbegin();
    out.push_back(ind);
    if (out.size()) {
      for (int i = 1; i <= n; i++) {
        if (ans.find(i) == ans.end()) {
          out.push_back(-1 * i);
          out.push_back(i);
        }
      }
    }
    ind = 1;
    for (auto i = ans.rbegin(); i != ans.rend(); i++) {
      if (i == ans.rbegin()) continue;
      out.push_back(*i);
    }
    cout << out.size() << "\n";
    for (auto i : out) cout << i << " ";
    cout << "\n";
  }
}
