#include <bits/stdc++.h>
using namespace std;
const int N = 77;
int T, n, k, f[N][N];
bool g[N][N], c[N];
void qr(int &x) { scanf("%d", &x); }
struct node {
  int a, b, id;
  bool operator<(node t) const { return b < t.b; }
} a[N];
int main() {
  qr(T);
  while (T--) {
    qr(n);
    qr(k);
    for (int i = 1; i <= n; i++) qr(a[i].a), qr(a[i].b), a[i].id = i;
    sort(a + 1, a + n + 1);
    memset(f, 0xcf, sizeof f);
    for (int i = 0; i <= n; i++) f[i][0] = 0;
    for (int i = 1; i <= n; i++)
      for (int j = 1; j <= k; j++)
        f[i][j] = max(f[i - 1][j], f[i - 1][j - 1] + a[i].a + (j - 1) * a[i].b),
        g[i][j] = f[i][j] ^ f[i - 1][j];
    for (int i = n, j = k; j; i--)
      if (g[i][j])
        c[i] = j--;
      else
        c[i] = 0;
    printf("%d\n", k + (n - k) * 2);
    for (int i = 1, j = 0; i <= n; i++) {
      if (j == k - 1) {
        for (int x = 1; x <= n; x++)
          if (!c[x]) printf("%d %d ", a[x].id, -a[x].id);
      }
      if (c[i]) printf("%d ", a[i].id), j++;
    }
    puts("");
  }
  return 0;
}
