#include <bits/stdc++.h>
using namespace std;
const long long INF = 1e18;
int n, k;
pair<int, int> a[80];
long long dp[80][80];
bool sel[80][80];
int id[80];
void solve() {
  cin >> n >> k;
  for (int i = 1; i <= n; ++i) {
    cin >> a[i].first;
    cin >> a[i].second;
  }
  for (int i = 1; i <= n; ++i) id[i] = i;
  sort(id + 1, id + 1 + n, [&](int x, int y) {
    return (a[x].second == a[y].second ? a[x].first > a[y].first
                                       : a[x].second < a[y].second);
  });
  for (int i = 0; i <= n; ++i) {
    for (int j = 0; j <= k; ++j) {
      dp[i][j] = -INF;
      sel[i][j] = false;
    }
  }
  dp[0][0] = 0;
  for (int i = 1; i <= n; ++i) {
    for (int j = 0; j <= min(i, k); ++j) {
      if (j < k)
        dp[i][j] = dp[i - 1][j] + a[id[i]].second * j;
      else
        dp[i][j] = dp[i - 1][j] + a[id[i]].second * (j - 1);
      sel[i][j] = 0;
      if (j > 0) {
        if (dp[i - 1][j - 1] + a[id[i]].second * (j - 1) + a[id[i]].first >
            dp[i][j]) {
          sel[i][j] = true;
        }
        dp[i][j] = max(dp[i][j], dp[i - 1][j - 1] + a[id[i]].second * (j - 1) +
                                     a[id[i]].first);
      }
    }
  }
  vector<int> ans, ans2;
  int cur = k;
  for (int i = n; i >= 1; --i) {
    if (sel[i][cur]) {
      cur--;
      ans.push_back(id[i]);
    } else {
      ans2.push_back(id[i]);
    }
  }
  reverse(ans.begin(), ans.end());
  cout << ans.size() + ans2.size() * 2 << '\n';
  for (int i = 0; i < ans.size() - 1; ++i) cout << ans[i] << ' ';
  for (int i = 0; i < ans2.size(); ++i)
    cout << ans2[i] << ' ' << -ans2[i] << ' ';
  cout << ans.back() << '\n';
}
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  int t;
  cin >> t;
  while (t--) solve();
}
