#include <bits/stdc++.h>
using namespace std;
template <typename T>
inline bool upmin(T &x, T y) {
  return y < x ? x = y, 1 : 0;
}
template <typename T>
inline bool upmax(T &x, T y) {
  return x < y ? x = y, 1 : 0;
}
const long double eps = 1e-11;
const long double pi = acos(-1);
const int oo = 1 << 30;
const long long loo = 1ll << 62;
const int mods = 1e9 + 7;
const int MAXN = 5005;
const int INF = 0x3f3f3f3f;
inline int read() {
  int f = 1, x = 0;
  char c = getchar();
  while (c < '0' || c > '9') {
    if (c == '-') f = -1;
    c = getchar();
  }
  while (c >= '0' && c <= '9') {
    x = (x << 3) + (x << 1) + (c ^ 48);
    c = getchar();
  }
  return x * f;
}
int a[105], b[105], f[105][105], flag[105], frm[105][105], id[105];
vector<int> V;
signed main() {
  int Case = read();
  while (Case--) {
    memset(f, -INF, sizeof f);
    memset(frm, 0, sizeof frm);
    memset(flag, 0, sizeof flag);
    int n = read(), k = read();
    for (int i = 1; i <= n; i++) a[i] = read(), b[i] = read(), id[i] = i;
    sort(id + 1, id + n + 1, [&](int x, int y) { return b[x] < b[y]; });
    V.clear();
    f[0][0] = 0;
    for (int i = 1; i <= n; i++)
      for (int j = 0; j <= k; j++) {
        if (j &&
            upmax(f[i][j], f[i - 1][j - 1] + a[id[i]] + b[id[i]] * (j - 1)))
          frm[i][j] = 1;
        if (upmax(f[i][j], f[i - 1][j] + b[id[i]] * (k - 1))) frm[i][j] = 2;
      }
    int nw = k;
    for (int i = n; i >= 1; i--)
      if (frm[i][nw] == 1)
        V.push_back(id[i]), nw--;
      else
        flag[i] = 1;
    for (int i = 0; i < V.size() - 1; i++) printf("%d ", V[i]);
    for (int i = 1; i <= n; i++)
      if (flag[i]) printf("%d -%d ", i, i);
    printf("%d\n", V[V.size() - 1]);
  }
  return 0;
}
