#include <bits/stdc++.h>
using namespace std;
const long long N = 1111;
long long te, n, k, x, y;
struct item {
  long long a, b, p;
} a[N], b[N];
bool cmp(item a, item b) { return a.a < b.a; }
bool cmp1(item a, item b) { return a.b < b.b; }
long long f() {
  long long ans = 0, mx = 0;
  for (long long i = 1; i <= n; i++) b[i] = a[i];
  for (long long i = 2; i < k; i++)
    if (cmp1(b[i], b[i - 1])) swap(b[i], b[i - 1]);
  for (long long i = k - 1; i >= 2; i--)
    if (cmp1(b[i], b[i - 1])) swap(b[i], b[i - 1]);
  for (long long i = 1; i < k; i++) ans += b[i].a + b[i].b * (i - 1);
  for (long long i = k; i <= n; i++)
    ans += b[i].b * (k - 1), mx = max(mx, b[i].a);
  return ans + mx;
}
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  cin >> te;
  srand(time(0));
  for (; te--;) {
    cin >> n >> k;
    for (long long i = 1; i <= n; i++) cin >> a[i].a >> a[i].b, a[i].p = i;
    if (k == 1) {
      cout << 1 << endl << a[n].p << endl;
      continue;
    }
    sort(a + 1, a + k, &cmp1);
    for (long long ch = 1; ch;) {
      ch = 0;
      x = f();
      for (long long i = 1; i < k; i++)
        for (long long j = k; j <= n; j++) {
          swap(a[i], a[j]);
          y = f();
          if (x < y) {
            ch = 1;
            x = y;
            for (long long ii = 2; ii < k; ii++)
              if (cmp1(a[ii], a[ii - 1])) swap(a[ii], a[ii - 1]);
            for (long long ii = k - 1; ii >= 2; ii--)
              if (cmp1(a[ii], a[ii - 1])) swap(a[ii], a[ii - 1]);
            break;
          }
          swap(a[i], a[j]);
        }
    }
    cout << k + (n - k) * 2 << endl;
    sort(a + k, a + n + 1, &cmp);
    for (long long i = 1; i < k; i++) cout << a[i].p << " ";
    for (long long i = k; i < n; i++) cout << a[i].p << " " << -a[i].p << " ";
    cout << a[n].p << endl;
  }
}
