#include <bits/stdc++.h>
using namespace std;
const int le = 76;
struct mon {
  int i = 0;
  long long power = 0;
  long long group = 0;
  bool operator<(const mon& other) const {
    if (this->group == other.group) {
      return this->power > other.power;
    }
    return this->group < other.group;
  }
};
long long dp[le][le];
mon a[le];
int role[le];
int main() {
  iostream::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  int q;
  cin >> q;
  while (q--) {
    int n, k;
    cin >> n >> k;
    for (int i = 0; i < n; i++) {
      cin >> a[i].power >> a[i].group;
      a[i].i = i;
    }
    for (int i = 0; i <= n; i++) {
      for (int j = 0; j <= k; j++) {
        dp[i][j] = -1;
      }
    }
    fill(role, role + n, 0);
    sort(a, a + n);
    dp[0][0] = 0;
    for (int i = 0; i < n; i++) {
      for (int j = 0; j <= k; j++) {
        if (dp[i][j] == -1) continue;
        if (j < k) {
          dp[i + 1][j + 1] =
              max(dp[i + 1][j + 1], dp[i][j] + a[i].group * j + a[i].power);
        }
        dp[i + 1][j] = max(dp[i + 1][j], dp[i][j] + a[i].group * (k - 1));
      }
    }
    int x, y;
    x = n;
    y = k;
    while (x > 0) {
      if (dp[x - 1][y] + a[x - 1].group * (k - 1) == dp[x][y]) {
        role[x - 1] = 1;
      } else {
        y--;
      }
      x--;
    }
    cout << 2 * n - k << endl;
    for (int i = 0; i < n && k > 1; i++) {
      if (role[i] == 0) {
        cout << a[i].i + 1 << ' ';
        k--;
      }
    }
    for (int i = 0; i < n; i++) {
      if (role[i] == 1) {
        cout << a[i].i + 1 << ' ' << -(a[i].i + 1) << ' ';
      }
    }
    for (int i = n - 1; i >= 0; i--) {
      if (role[i] == 0) {
        cout << a[i].i + 1 << endl;
        break;
      }
    }
  }
  return 0;
}
