#include <bits/stdc++.h>
using namespace std;
const double eps = 1e-7;
const int N = 100;
const int M = 200010;
const int P = 1000000007;
const int Inf = 1000000007;
const int Fni = -1000000007;
inline int qr() {
  int r = 0, f = 1;
  char c = getchar();
  while (c > '9' || c < '0') {
    if (c == '-') f = -1;
    c = getchar();
  }
  while (c <= '9' && c >= '0') {
    r = (r << 1) + (r << 3) + c - '0', c = getchar();
  }
  return r * f;
}
template <typename T>
void debug(T x, char c = '\n') {
  cerr << x << c;
}
template <typename T>
void debug(T *const tp, int minn, int maxn, char v = ' ', char c = '\n') {
  for (int i = minn; i <= maxn; ++i) debug(tp[i], v);
  cerr << c;
}
template <typename T>
inline void chkmin(T &x, T y) {
  x = x > y ? y : x;
}
template <typename T>
inline void chkmax(T &x, T y) {
  x = x < y ? y : x;
}
template <typename T>
inline void add(T &x, long long y, int mod = P) {
  x += y;
  x = x >= mod ? x - mod : x;
}
template <typename T>
inline void dec(T &x, long long y, int mod = P) {
  x -= y;
  x = x < 0 ? x + mod : x;
}
template <typename T>
inline T addn(T x, long long y, int mod = P) {
  x += y;
  return (x = x > mod ? x - mod : x);
}
template <typename T>
inline T decn(T x, long long y, int mod = P) {
  x -= y;
  return (x = x < 0 ? x + mod : x);
}
int T;
struct minion {
  int a, b, id;
} base[N], tmp[N];
int n, k;
int cnt;
int ans;
int lst;
int ud[N];
int qwq[N];
int f[N][N];
int pre[N][N];
bool comp(minion x, minion y) { return x.a == y.a ? x.b < y.b : x.a > y.a; }
bool cop(minion x, minion y) { return x.b < y.b; }
int main() {
  cin >> T;
  while (T--) {
    cin >> n >> k;
    ans = cnt = 0;
    fill(ud, ud + n + 1, 0);
    memset(f, -63, sizeof(f));
    for (int i = 1; i <= n; ++i)
      base[i].a = qr(), base[i].id = i, base[i].b = qr();
    sort(base + 1, base + n + 1, comp);
    f[0][0] = 1;
    for (int i = 1; i <= n; ++i)
      for (int j = 0; j <= k - 1; ++j) {
        int tmp = base[i].b * (j - k);
        if (!j)
          f[i][j] = f[i - 1][j], pre[i][j] = 0;
        else {
          if (f[i - 1][j] > f[i - 1][j - 1] + base[i].a + tmp)
            f[i][j] = f[i - 1][j], pre[i][j] = 0;
          else
            f[i][j] = f[i - 1][j - 1] + base[i].a + tmp, pre[i][j] = 1;
        }
      }
    int p = n, q = k - 1;
    while (p && q) {
      if (!pre[p][q])
        --p;
      else
        ud[base[p].id] = 1, --q, --p;
    }
    for (int i = 1; i <= n; ++i)
      if (!ud[base[i].id]) qwq[++cnt] = i;
    for (int i = 1; i <= cnt; ++i) {
      int res = 0, gz = 0;
      for (int j = 1; j <= cnt; ++j)
        if (i != j) tmp[++gz] = base[qwq[j]];
      sort(tmp + 1, tmp + gz + 1, cop);
      for (int j = 1; j <= gz; ++j) res += (k - 1) * tmp[j].b;
      res += base[qwq[i]].a + base[qwq[i]].b * (k - 1);
      if (res >= ans) ans = res, lst = qwq[i];
    }
    cout << k - 1 + 2 * (n - k) + 1 << '\n';
    for (int i = 1; i <= n; ++i)
      if (ud[i]) cout << i << ' ';
    for (int i = 1; i <= cnt; ++i)
      if (qwq[i] != lst)
        cout << base[qwq[i]].id << ' ' << -base[qwq[i]].id << ' ';
    cout << base[lst].id << "\n";
  }
  return 0;
}
