#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;
long long t, n, k, dp[maxn][maxn], path[maxn][maxn], gr1[maxn], gr2[maxn], tot1,
    tot2;
struct Node {
  long long a, b, id;
  bool operator<(const Node A) const { return b < A.b; }
} st[maxn];
int main() {
  scanf("%lld", &t);
  memset(dp[0] + 1, -1, sizeof(dp[0] + 1));
  while (t--) {
    scanf("%lld%lld", &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);
    for (register int i = 1; i < (n + 1); ++i)
      for (register int j = 0; j < (min((int)k, i) + 1); ++j) {
        if (dp[i - 1][j] != -1)
          dp[i][j] = dp[i - 1][j] + (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 + (j - 1ll) * st[i].b) {
            dp[i][j] = dp[i - 1][j - 1] + st[i].a + (j - 1ll) * st[i].b;
            path[i][j] = j - 1;
          }
        }
        if (dp[i][j] == -inf) dp[i][j] = -1;
      }
    long long 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("%lld\n", tot1 + tot2 * 2ll);
    for (register int i = tot1 - 1; i >= (1); --i) printf("%lld ", gr1[i]);
    for (register int i = tot2 - 1; i >= (0); --i)
      printf("%lld %lld ", gr2[i], -gr2[i]);
    printf("%lld\n", gr1[0]);
  }
}
