#include <bits/stdc++.h>
using namespace std;
struct ANS {
  int sss, i;
  ANS *to;
  bool operator>(const ANS a) const { return sss > a.sss; }
} dp[80][80];
ANS max_get(ANS a, ANS b, ANS *aa, ANS *bb, int i) {
  ANS s;
  if (a > b) {
    s.sss = a.sss;
    s.i = 0;
    s.to = aa;
  } else {
    s.sss = b.sss;
    s.i = i;
    s.to = bb;
  }
  return s;
}
struct node {
  int a, b, i;
  bool operator<(const node x) const { return b < x.b; }
} mp[80];
int n, m, T;
bool vis[80];
void print(ANS *x) {
  if (x == NULL) return;
  print(x->to);
  if (x->i) {
    printf("%d ", mp[x->i].i);
    vis[x->i] = 1;
  }
}
int main() {
  scanf("%d", &T);
  while (T--) {
    memset(vis, 0, sizeof(vis));
    scanf("%d%d", &n, &m);
    for (int i = 1; i <= n; i++) {
      scanf("%d%d", &mp[i].a, &mp[i].b);
      mp[i].i = i;
    }
    sort(mp + 1, mp + n + 1);
    if (n <= m) {
      printf("%d\n", n);
      for (int i = 1; i <= n; i++) printf("%d ", mp[i].i);
      printf("\n");
      continue;
    }
    for (int i = 0; i <= n; i++)
      for (int j = 0; j <= m; j++) {
        dp[i][j].sss = -0x3f3f3f3f;
        dp[i][j].i = 0;
        dp[i][j].to = NULL;
      }
    dp[0][0].sss = 0;
    for (int i = 1; i <= n; i++) {
      dp[i][0].i = 0;
      dp[i][0].to = &dp[i - 1][0];
      dp[i][0].sss = dp[i - 1][0].sss + mp[i].b * (n - 1);
      for (int j = 1; j <= m; j++) {
        ANS xa = dp[i - 1][j], xb = dp[i - 1][j - 1];
        xa.sss += mp[i].b * (m - 1);
        xb.sss += mp[i].b * (j - 1) + mp[i].a;
        dp[i][j] = max_get(xa, xb, &dp[i - 1][j], &dp[i - 1][j - 1], i);
      }
    }
    printf("%d\n", 2 * n - m);
    ANS re = dp[n][m];
    while (!re.i) re = *(re.to);
    print(re.to);
    vis[re.i] = 1;
    for (int i = 1; i <= n; i++)
      if (!vis[i]) printf("%d -%d ", mp[i].i, mp[i].i);
    printf("%d\n", mp[re.i].i);
  }
  return 0;
}
