#include <bits/stdc++.h>
using namespace std;
const int N = 1e6 + 5;
int t, k, n;
vector<int> arr;
long long A[100];
long long B[100];
int ord[100];
bool byB(int x, int y) { return B[x] < B[y]; }
bool byOrd(int x, int y) { return ord[x] < ord[y]; }
long long mem[100][100];
long long dp(int pos, int inK) {
  if (pos == n) return 0;
  if (mem[pos][inK] != -1) return mem[pos][inK];
  long long &ret = mem[pos][inK];
  if (inK == k) return ret = dp(pos + 1, inK) + B[arr[pos]] * long long(k - 1);
  return ret = max(
             dp(pos + 1, inK) + B[arr[pos]] * long long(k - 1),
             dp(pos + 1, inK + 1) + A[arr[pos]] + B[arr[pos]] * long long(inK));
}
void solve() {
  int pos = 0, inK = 0, outK = k;
  for (; pos < n; pos++) {
    if (dp(pos, inK) == dp(pos + 1, inK) + B[arr[pos]] * long long(k - 1))
      ord[arr[pos]] = outK++;
    else if (inK < k - 1)
      ord[arr[pos]] = ++inK;
    else
      ord[arr[pos]] = n;
  }
  sort(arr.begin(), arr.end(), byOrd);
  int last = 0;
  cout << n + (n - k) << endl;
  for (int i = 0; i < n; i++) {
    if (i >= k) cout << -last << " ";
    cout << arr[i] << " ";
    last = arr[i];
  }
  cout << endl;
}
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  memset(mem, -1, sizeof(mem));
  cin >> t;
  while (t--) {
    arr.clear();
    cin >> n >> k;
    for (int i = 0; i < n; i++) {
      cin >> A[i + 1] >> B[i + 1];
      arr.push_back(i + 1);
    }
    sort(arr.begin(), arr.end(), byB);
    dp(0, 0);
    solve();
  }
  return 0;
}
