#include <bits/stdc++.h>
using namespace std;
const int N = 75;
int T, n, m, dp[N][N], from[N][N], id[N], flag[N];
struct Ask {
  int x, y, from;
} A[N];
int cmp(Ask x, Ask y) { return x.y < y.y; }
int main() {
  scanf("%d", &T);
  while (T--) {
    scanf("%d%d", &n, &m);
    for (int i = 0; i < n; i++)
      scanf("%d%d", &A[i].x, &A[i].y), A[i].from = i + 1;
    sort(A, A + n, cmp);
    memset(dp, 0xcf, sizeof dp);
    dp[0][0] = 0;
    for (int i = 0; i < n; i++)
      for (int j = 0; j <= m; j++) {
        if (j <= m && dp[i + 1][j + 1] < dp[i][j] + A[i].x + A[i].y * j) {
          dp[i + 1][j + 1] = dp[i][j] + A[i].x + A[i].y * j;
          from[i + 1][j + 1] = 0;
        }
        if (dp[i + 1][j] < dp[i][j] + A[i].y * (m - 1))
          dp[i + 1][j] = dp[i][j], from[i + 1][j] = 1;
      }
    int now = m;
    for (int i = n; i; i--) {
      if (!from[i][now])
        id[now] = A[i - 1].from, flag[i - 1] = 0, now--;
      else
        flag[i - 1] = 1;
    }
    printf("%d\n", n * 2 - m);
    for (int i = 1; i < m; i++) printf("%d ", id[i]);
    for (int i = 0; i < n; i++)
      if (flag[i]) printf("%d %d ", A[i].from, -A[i].from);
    printf("%d\n", id[m]);
  }
}
