#include <bits/stdc++.h>
#pragma GCC optimize("O3")
using namespace std;
template <class T>
inline void amin(T &x, const T &y) {
  if (y < x) x = y;
}
template <class T>
inline void amax(T &x, const T &y) {
  if (x < y) x = y;
}
template <class Iter>
void rprintf(const char *fmt, Iter begin, Iter end) {
  for (bool sp = 0; begin != end; ++begin) {
    if (sp)
      putchar(' ');
    else
      sp = true;
    printf(fmt, *begin);
  }
  putchar('\n');
}
struct Data {
  long long a, b;
  int i;
  bool operator<(const Data &o) const { return b < o.b; }
};
int N, K;
Data P[77];
long long dp[77][77];
long long solve(int last) {
  P[N] = P[last];
  memset(dp, 0xc0, sizeof dp);
  dp[0][0] = 0;
  for (int i = 0, i_len = (N + 1); i < i_len; ++i) {
    for (int j = 0, j_len = (K); j < j_len; ++j) amax(dp[i + 1][j], dp[i][j]);
    if (i == last) continue;
    for (int j = 0, j_len = (K); j < j_len; ++j)
      amax(dp[i + 1][j + 1], dp[i][j] + P[i].a + j * P[i].b);
    for (int j = 0, j_len = (K); j < j_len; ++j)
      amax(dp[i + 1][j], dp[i][j] + (K - 1) * P[i].b);
  }
  return dp[N + 1][K];
}
void MAIN() {
  scanf("%d%d", &N, &K);
  for (int i = 0, i_len = (N); i < i_len; ++i) {
    scanf("%lld%lld", &P[i].a, &P[i].b);
    P[i].i = i;
  }
  sort(P, P + N);
  pair<long long, int> best(-1, 0);
  for (int i = 0, i_len = (N); i < i_len; ++i) {
    long long tmp = solve(i);
    amax(best, make_pair(tmp, i));
  }
  solve(best.second);
  int x = K;
  vector<int> ans;
  for (int i = N + 1; i--;) {
    if (i == best.second) continue;
    if (x < K && dp[i + 1][x] == dp[i][x]) {
    } else if (dp[i + 1][x] == dp[i][x - 1] + P[i].a + (x - 1) * P[i].b) {
      ans.push_back(P[i].i + 1);
      x--;
    } else if (dp[i + 1][x] == dp[i][x] + (K - 1) * P[i].b) {
      ans.push_back(-(P[i].i + 1));
      ans.push_back(P[i].i + 1);
    } else {
      assert(false);
    }
  }
  assert(x == 0);
  printf("%d\n", (int)ans.size());
  rprintf("%d", ans.rbegin(), ans.rend());
}
int main() {
  int TC = 1;
  scanf("%d", &TC);
  for (int tc = 0, tc_len = (TC); tc < tc_len; ++tc) MAIN();
  return 0;
}
