#include <bits/stdc++.h>
using namespace std;
const int maxn = 80;
int f[maxn][maxn], pre[maxn][maxn];
int n, k, id[maxn], a[maxn], b[maxn];
void solve() {
  scanf("%d%d", &n, &k);
  for (int(i) = (1); (i) <= (n); (i)++) scanf("%d%d", a + i, b + i);
  iota(id + 1, id + n + 1, 1);
  sort(id + 1, id + n + 1, [&](int i, int j) { return b[i] < b[j]; });
  memset(f, 0, sizeof(f));
  int bi = 0, bj = 0;
  for (int(i) = (1); (i) <= (n); (i)++)
    for (int(j) = (0); (j) <= ((min(i + 1, k + 1)) - 1); (j)++) {
      if (j != min(i, k)) {
        f[i][j] = f[i - 1][j] + j * b[id[i]];
        pre[i][j] = j;
      }
      if (j && f[i][j] < f[i - 1][j - 1] + a[id[i]] + (j - 1) * b[id[i]]) {
        f[i][j] = f[i - 1][j - 1] + a[id[i]] + (j - 1) * b[id[i]];
        pre[i][j] = j - 1;
        if (j == k) {
          int s = 0;
          for (int(l) = (i + 1); (l) <= (n); (l)++) s += (k - 1) * b[id[l]];
          if (f[i][j] + s > f[bi][bj]) {
            bi = i;
            bj = j;
            f[i][j] += s;
          }
        }
      }
    }
  int j = pre[bi][bj];
  stack<int> ans;
  ans.emplace(id[bi]);
  for (int(l) = (n); (l) >= (bi + 1); (l)--) {
    ans.emplace(-id[l]);
    ans.emplace(id[l]);
  }
  for (int(i) = (bi - 1); (i) >= (1); (i)--) {
    if (pre[i][j] == j) ans.emplace(-id[i]);
    ans.emplace(id[i]);
    j = pre[i][j];
  }
  printf("%lu\n", ans.size());
  while (!ans.empty()) {
    printf("%d ", ans.top());
    ans.pop();
  }
  putchar('\n');
}
int main() {
  int T;
  scanf("%d", &T);
  while (T--) solve();
}
