#include <bits/stdc++.h>
using namespace std;
template <class A>
ostream& operator<<(ostream& out, const vector<A>& v) {
  out << "[";
  for (int ind = 0; ind < int(int(v.size())); ++ind) {
    if (ind) out << ", ";
    out << v[ind];
  }
  return out << "]";
}
template <class A, class B>
ostream& operator<<(ostream& out, const pair<A, B>& p) {
  return out << "(" << p.x << ", " << p.y << ")";
}
const int INF = int(1e9);
const long long int INF64 = long long int(1e18);
const int MOD = int(1e9) + 7;
const long double EPS = 1e-9;
const long double PI = acos(-1.0);
const int N = 75 + 1;
int n, k;
pair<pair<int, int>, int> minions[N];
bool read() {
  if (scanf("%d %d", &n, &k) != 2) return false;
  for (int id = 0; id < int(n); ++id) {
    scanf("%d%d", &minions[id].first.first, &minions[id].first.first);
    minions[id].second = id;
  }
  return true;
}
int dp[N][N];
int pos[N][N];
void solve() {
  sort(
      minions, minions + n,
      [](pair<pair<int, int>, int> minion1, pair<pair<int, int>, int> minion2) {
        return minion1.first.second != minion2.first.second
                   ? minion1.first.second < minion2.first.second
                   : minion1.first.first < minion2.first.first;
      });
  memset(dp, -INF, sizeof(dp));
  dp[0][0] = 0;
  for (int m = 0; m < int(n); ++m) {
    for (int fgCnt = 0; fgCnt < int(m); ++fgCnt) {
      int a = minions[m].first.first;
      int b = minions[m].first.second;
      if (dp[m][fgCnt] >= 0) {
        if (dp[m + 1][fgCnt + 1] < dp[m][fgCnt] + a + fgCnt * b) {
          dp[m + 1][fgCnt + 1] = dp[m][fgCnt] + a + fgCnt * b;
          pos[m + 1][fgCnt + 1] = fgCnt;
        }
        if (dp[m + 1][fgCnt] < dp[m][fgCnt] + (k - 1) * b) {
          dp[m + 1][fgCnt] = dp[m][fgCnt] + (k - 1) * b;
          pos[m + 1][fgCnt] = fgCnt;
        }
      }
    }
  }
  vector<int> fg, sg;
  int fgCnt = k;
  for (int m = n; m > 0; --m) {
    if (pos[m][fgCnt] == fgCnt) {
      sg.push_back(minions[m - 1].second + 1);
    } else {
      fg.push_back(minions[m - 1].second + 1);
    }
    fgCnt = pos[m][fgCnt];
  }
  reverse(begin(fg), end(fg));
  reverse(begin(sg), end(sg));
  printf("%d\n", int(fg.size()) + 2 * int(sg.size()));
  for (int ind = 0; ind < int(int(fg.size()) - 1); ++ind)
    printf("%d ", fg[ind]);
  for (int m : sg) printf("%d %d ", m, -m);
  printf("%d\n", fg.back());
}
int main() {
  cerr.precision(15);
  cout.precision(15);
  cerr << fixed;
  cout << fixed;
  int t;
  scanf("%d", &t);
  while (read()) solve();
  return 0;
}
