#include <bits/stdc++.h>
using namespace std;
struct minion {
  int a, b, id;
};
bool sorta(minion x, minion y) { return x.a > y.a; }
int n, k;
minion ar[100];
pair<int, vector<minion>> calc(int except) {
  int cur = ar[except].a + (k - 1) * ar[except].b;
  vector<minion> v;
  for (int i = 0; i < n; ++i)
    if (i != except) v.push_back(ar[i]);
  sort(v.begin(), v.end(), sorta);
  int cnt = n;
  while (cnt--) {
    for (int i = 0; i < v.size() - 1; ++i) {
      int val1 = v[i].b * min(i, k - 1) + v[i + 1].b * min(i + 1, k - 1);
      if (i < k - 1) val1 += v[i].a;
      if (i + 1 < k - 1) val1 += v[i + 1].a;
      int val2 = v[i + 1].b * min(i, k - 1) + v[i].b * min(i + 1, k - 1);
      if (i < k - 1) val2 += v[i + 1].a;
      if (i + 1 < k - 1) val2 += v[i].a;
      if (val2 > val1) swap(v[i], v[i + 1]);
    }
  }
  for (int i = 0; i < v.size(); ++i)
    cur += v[i].b * min(i, k - 1) + v[i].a * (i < k - 1);
  v.push_back(ar[except]);
  return {cur, v};
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);
  int t;
  cin >> t;
  while (t--) {
    cin >> n >> k;
    for (int i = 0; i < n; ++i) {
      cin >> ar[i].a >> ar[i].b;
      ar[i].id = i;
    }
    pair<int, vector<minion>> ans;
    ans.first = -1e9;
    for (int i = 0; i < n; ++i) {
      pair<int, vector<minion>> neww = calc(i);
      if (neww.first > ans.first) ans = neww;
    }
    cout << n + (n - k) << '\n';
    for (int i = 0; i < k - 1; ++i) cout << ans.second[i].id + 1 << ' ';
    for (int i = k - 1; i < n - 1; ++i)
      cout << ans.second[i].id + 1 << " -" << ans.second[i].id + 1 << ' ';
    cout << ans.second[n - 1].id + 1 << '\n';
  }
}
