#include <bits/stdc++.h>
using namespace std;
const int maxn = 80;
int n, dp[maxn], old[maxn], k;
bool cer[maxn][maxn][maxn];
struct minion {
  int a, b, i;
} m[maxn];
int main() {
  ios::sync_with_stdio(0), cin.tie(0);
  int t;
  cin >> t;
  while (t--) {
    cin >> n >> k;
    for (int i = 0; i < n; i++) cin >> m[i].a >> m[i].b, m[i].i = i;
    sort(m, m + n, [](minion a, minion b) { return a.b < b.b; });
    int ans = 0, cerl;
    for (int last = 0; last < n; last++) {
      memset(dp, -63, sizeof dp);
      dp[0] = 0;
      for (int i = 0; i < n; i++)
        if (i != last) {
          for (int j = k - 1; j > 0; j--) {
            cer[last][i][j] =
                dp[j] + m[i].b * j < dp[j - 1] + m[i].b * (j - 1) + m[i].a;
            dp[j] =
                max(dp[j] + m[i].b * j, dp[j - 1] + m[i].b * (j - 1) + m[i].a);
          }
        }
      if (ans < m[last].a + m[last].b * (k - 1) + dp[k - 1])
        cerl = last, ans = m[last].a + m[last].b * (k - 1) + dp[k - 1];
    }
    vector<int> come, app;
    for (int i = n - 1, j = k - 1; i >= 0; i--)
      if (i != cerl)
        if (cer[cerl][i][j])
          come.push_back(i), j--;
        else
          app.push_back(i);
    reverse(come.begin(), come.end());
    cout << come.size() + app.size() * 2 + 1 << '\n';
    for (auto i : come) cout << m[i].i + 1 << ' ';
    for (auto i : app) cout << m[i].i + 1 << ' ' << -m[i].i - 1 << ' ';
    cout << m[cerl].i + 1 << '\n';
  }
}
