#include <bits/stdc++.h>
using namespace std;
const int maxn = 1e2 + 5;
int a[maxn], b[maxn], dp[maxn][maxn][maxn], vis[maxn];
int main() {
  int T;
  scanf("%d", &T);
  while (T--) {
    int n, kk;
    scanf("%d%d", &n, &kk);
    for (int i = 1; i <= n; i++) {
      scanf("%d%d", a + i, b + i);
      b[i] *= kk - 1;
    }
    memset(dp, -1, sizeof(dp));
    dp[0][0][0] = 0;
    for (int i = 1; i <= n; i++)
      for (int j = 0; j <= kk; j++)
        for (int k = 0; k <= n - kk; k++) {
          if (j && dp[i - 1][j - 1][k] != -1)
            dp[i][j][k] = dp[i - 1][j - 1][k] + a[i];
          if (k && dp[i - 1][j][k - 1] != -1)
            dp[i][j][k] = max(dp[i][j][k], dp[i - 1][j][k - 1] + b[i]);
        }
    int j = kk, k = n - kk;
    memset(vis, -1, sizeof(vis));
    for (int i = n; i; i--) {
      if (j && dp[i][j][k] == dp[i - 1][j - 1][k] + a[i]) {
        j--;
        vis[i] = 0;
      } else if (k && dp[i][j][k] == dp[i - 1][j][k - 1] + b[i]) {
        k--;
        vis[i] = 1;
      }
    }
    printf("%d\n", kk + (n - kk) * 2);
    for (int i = 1; i <= n && kk > 1; i++)
      if (!vis[i]) {
        printf("%d ", i);
        kk--;
      }
    for (int i = 1; i <= n; i++)
      if (vis[i] == 1) {
        printf("%d %d ", i, -i);
      }
    for (int i = n; i; i--)
      if (!vis[i]) {
        printf("%d\n", i);
        break;
      }
  }
  return 0;
}
