#include <bits/stdc++.h>
using namespace std;
int dp[80][80], dir[80][80];
struct minion {
  int pow, add;
} a[80];
int ind[80];
static inline void refresh() {
  for (int i = 0; i < 80; ++i) {
    ind[i] = a[i].pow = a[i].add = 0;
    for (int j = 0; j < 80; ++j) {
      dp[i][j] = dir[i][j] = 0;
    }
  }
}
struct cmp {
  inline bool operator()(const int &x, const int &y) {
    return a[x].add < a[y].add;
  }
};
int dx[] = {-1, -1};
int dy[] = {0, -1};
vector<int> mvs;
void mkMoves(int i, int j) {
  mvs.clear();
  while (i) {
    int q = dir[i][j] - 1;
    if (q) {
      mvs.push_back(ind[i]);
    } else {
      mvs.push_back(-ind[i]);
      mvs.push_back(ind[i]);
    }
    i += dx[q];
    j += dy[q];
  }
  reverse(mvs.begin(), mvs.end());
  cout << mvs.size() << "\n";
  for (int i = 0; i < mvs.size(); ++i) {
    cout << mvs[i] << " ";
  }
  cout << "\n\n";
}
int main() {
  int t, n, k;
  cin >> t;
  while (t--) {
    cin >> n >> k;
    refresh();
    for (int i = 1; i <= n; ++i) {
      cin >> a[i].pow >> a[i].add;
      ind[i] = i;
    }
    sort(ind, ind + n, cmp());
    for (int i = 1; i <= n; ++i) {
      for (int j = 0; j <= k && j <= i; ++j) {
        int l = 0, r = 0;
        if (j >= 1) {
          l = dp[i - 1][j - 1] + a[ind[i]].pow + (j - 1) * a[ind[i]].add;
        }
        if (j < i) {
          r = dp[i - 1][j] + (k - 1) * a[ind[i]].add;
        }
        dp[i][j] = max(l, r);
        if (l < r) {
          dir[i][j] = 1;
        } else {
          dir[i][j] = 2;
        }
      }
    }
    mkMoves(n, k);
  }
  return 0;
}
