#include <bits/stdc++.h>
using namespace std;
void Freopen() {
  freopen(
      "title"
      ".in",
      "r", stdin);
  freopen(
      "title"
      ".out",
      "w", stdout);
}
int read() {
  int g = 0, f = 1;
  char ch = getchar();
  while (ch < '0' || '9' < ch) {
    if (ch == '-') f = -1;
    ch = getchar();
  }
  while ('0' <= ch && ch <= '9') {
    g = g * 10 + ch - '0';
    ch = getchar();
  }
  return g * f;
}
const int N = 80;
const int INF = 1e9;
struct node {
  int a, b, id;
} p[N];
int f[N][N], n, m, from[N][N], ans[N], vis[N];
void solve() {
  n = read(), m = read();
  for (int i = (1); i <= (n); i++) p[i] = node{read(), read(), i};
  sort(p + 1, p + n + 1, [](node x, node y) { return x.b < y.b; });
  for (int i = (0); i <= (n); i++)
    for (int j = (0); j <= (m); j++) f[i][j] = -INF;
  f[0][0] = 0;
  for (int i = (1); i <= (n); i++)
    for (int j = (1); j <= (m); j++) {
      if (f[i - 1][j] + (m - 1) * p[i].b > f[i][j])
        f[i][j] = f[i - 1][j] + (m - 1) * p[i].b, from[i][j] = j;
      if (f[i - 1][j - 1] + (j - 1) * p[i].b + p[i].a > f[i][j])
        f[i][j] = f[i - 1][j - 1] + (j - 1) * p[i].b + p[i].a,
        from[i][j] = j - 1;
    }
  int now = m, cnt = 0;
  memset(vis, 0, sizeof(vis));
  for (int i = (n); i >= (1); i--)
    if (from[i][now] == now - 1) ans[++cnt] = p[i].id, now--, vis[p[i].id] = 1;
  for (int i = (cnt); i >= (2); i--) cout << ans[i] << ' ';
  for (int i = (1); i <= (n); i++)
    if (!vis[i]) cout << i << " -" << i << ' ';
  cout << ans[1] << '\n';
}
signed main() {
  for (int T = read(); T--;) solve();
  return signed();
}
