#include <bits/stdc++.h>
using namespace std;
const int maxn = 100;
const int inf = 2147483647;
const double pi = 3.1415926576;
const long long INF = 9223372036854775807ll;
int t, n, k, path[maxn][maxn], gr1[maxn], gr2[maxn], tot1, tot2;
long long dp[maxn][maxn];
struct Node {
  long long a, b;
  int id;
} st[maxn];
bool cmp(Node a, Node b) { return a.b < b.b || a.b == b.b && a.a < b.a; }
int main() {
  scanf("%d", &t);
  for (register int i = 1; i < (maxn); ++i) dp[0][i] = -1;
  while (t--) {
    scanf("%d%d", &n, &k);
    for (register int i = 1; i < (n + 1); ++i) {
      scanf("%lld%lld", &st[i].a, &st[i].b);
      st[i].id = i;
    }
    sort(st + 1, st + 1 + n, cmp);
    for (register int i = 1; i < (n + 1); ++i)
      for (register int j = 0; j < (min(k, i) + 1); ++j) {
        if (dp[i - 1][j] != -1)
          dp[i][j] = dp[i - 1][j] + ((long long)k - 1ll) * st[i].b,
          path[i][j] = j;
        else
          dp[i][j] = -INF;
        if (j && dp[i - 1][j - 1] != -1) {
          if (dp[i][j] <
              dp[i - 1][j - 1] + st[i].a + ((long long)j - 1ll) * st[i].b) {
            dp[i][j] =
                dp[i - 1][j - 1] + st[i].a + ((long long)j - 1ll) * st[i].b;
            path[i][j] = j - 1;
          }
        }
        if (dp[i][j] == -INF) dp[i][j] = -1;
      }
    int jj = path[n][k], pre = k, cnt = n;
    tot1 = tot2 = 0;
    while (cnt) {
      if (jj == pre)
        gr2[tot2++] = st[cnt].id;
      else
        gr1[tot1++] = st[cnt].id;
      cnt--, pre = jj;
      jj = path[cnt][jj];
    }
    printf("%d\n", tot1 + tot2 * 2);
    for (register int i = tot1 - 1; i >= (1); --i) printf("%d ", gr1[i]);
    for (register int i = tot2 - 1; i >= (0); --i)
      printf("%d %d ", gr2[i], -gr2[i]);
    printf("%d\n", gr1[0]);
  }
}
