#include <bits/stdc++.h>
using namespace std;
const int inf = 0x3f3f3f3f;
const long long INF = 0x3f3f3f3f3f3f3f3f;
const int N = 75;
struct ca {
  int a, b, id;
} c[N + 7];
int f[N + 7][N + 7], p[N + 7][N + 7], mk[N + 7];
int cmp(const ca first, const ca second) { return first.b < second.b; }
int cmp2(const ca first, const ca second) {
  if (mk[first.id] != mk[second.id]) return mk[first.id] > mk[second.id];
  return first.a < second.a;
}
void KonnyWen() {
  int n, k;
  scanf("%d%d", &n, &k), k--;
  for (int i = 1; i <= n; i++) scanf("%d%d", &c[i].a, &c[i].b), c[i].id = i;
  sort(c + 1, c + n + 1, cmp);
  fill(f[0] + 1, f[0] + k + 1, 0);
  for (int i = 1; i <= n; i++) {
    fill(f[i] + 1, f[i] + k + 1, 0);
    for (int j = 1; j <= min(i, k); j++) {
      if (f[i - 1][j - 1] + c[i].a + c[i].b * (j - 1) > f[i - 1][j])
        f[i][j] = f[i - 1][j - 1] + c[i].a + c[i].b * (j - 1), p[i][j] = i;
      else
        f[i][j] = f[i - 1][j], p[i][j] = p[i - 1][j];
    }
  }
  for (int i = k, j = p[n][k]; i >= 1; i--)
    mk[c[j].id] = 1, j = p[j - 1][i - 1];
  printf("%d\n", 2 * n - k - 1);
  for (int i = 1; i <= n; i++)
    if (mk[i]) printf("%d ", i);
  sort(c + 1, c + n + 1, cmp2);
  for (int i = k + 1; i <= n - 1; i++) printf("%d %d ", c[i].id, -c[i].id);
  printf("%d\n", c[n].id);
}
int main() {
  int t;
  scanf("%d", &t);
  while (t--) KonnyWen();
  return 0;
}
