#include <bits/stdc++.h>
using namespace std;
long long dp[75][75];
bool is[75][75];
bool act[75][75];
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  int q;
  cin >> q;
  while (q--) {
    int n, k;
    cin >> n >> k;
    vector<pair<int, int> > mini;
    vector<pair<int, int> > stats;
    long long a, b;
    long long ki = 1LL * k;
    for (int i = 0; i < n; i++) {
      cin >> a >> b;
      mini.push_back(make_pair(b, i));
      stats.push_back(make_pair(a, b));
    }
    for (int i = 0; i < n; i++) {
      for (int j = 0; j < n; j++) {
        dp[i][j] = 0;
        is[i][j] = false;
        act[i][j] = false;
      }
    }
    sort(mini.begin(), mini.end());
    dp[0][0] = (ki - 1LL) * (stats[mini[0].second].second);
    dp[0][1] = stats[mini[0].second].first;
    is[0][1] = true;
    is[0][0] = true;
    act[0][1] = true;
    for (int i = 0; i < n; i++)
      for (int i = 0; i < n - 1; i++) {
        a = stats[mini[i + 1].second].first;
        b = stats[mini[i + 1].second].second;
        for (int j = 0; j <= k; j++) {
          if (is[i][j]) {
            long long dead = b * (ki - 1LL);
            long long alive = a + b * (1LL * (j));
            is[i + 1][j] = true;
            if (dp[i + 1][j] < dp[i][j] + dead) {
              dp[i + 1][j] = dp[i][j] + dead;
              act[i + 1][j] = false;
            }
            is[i + 1][j + 1] = true;
            if (dp[i + 1][j + 1] < dp[i][j] + alive) {
              act[i + 1][j + 1] = true;
              dp[i + 1][j + 1] = dp[i][j] + alive;
            }
          }
        }
      }
    vector<int> vivos;
    vector<int> muertos;
    int current = k;
    for (int i = n - 1; i >= 0; i--) {
      if (act[i][current]) {
        vivos.push_back(i);
        current--;
      } else {
        muertos.push_back(i);
      }
    }
    cout << (vivos.size() + 2 * muertos.size()) << '\n';
    for (int i = 0; i < vivos.size() - 1; i++) {
      cout << (mini[vivos[i]].second + 1) << " ";
    }
    for (int i = 0; i < muertos.size(); i++) {
      cout << (mini[muertos[i]].second + 1) << " "
           << (-1 * (mini[muertos[i]].second + 1)) << " ";
    }
    cout << (mini[vivos[vivos.size() - 1]].second + 1) << '\n';
  }
  return 0;
}
