#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using i2 = pair<int, int>;
const int N = 80;
pair<i2, int> minions[N], A[N];
int dp[N][N];
bool take[N][N], is_taken[N];
int solve(int x, int n, int k) {
  for (int i = 1; i < x; i++) A[i] = minions[i];
  for (int i = x + 1; i <= n; i++) A[i - 1] = minions[i];
  for (int i = 1; i < n; i++) {
    int a = A[i].first.second;
    int b = A[i].first.first;
    for (int j = 0; j <= i; j++) dp[i][j] = -1;
    for (int j = 0; j < i; j++) {
      if (dp[i - 1][j] + (k - 1) * b > dp[i][j]) {
        dp[i][j] = dp[i - 1][j] + (k - 1) * b;
        take[i][j] = false;
      }
    }
    for (int j = 1; j <= i; j++) {
      if (dp[i - 1][j - 1] + a + (j - 1) * b > dp[i][j]) {
        dp[i][j] = dp[i - 1][j] + a + (j - 1) * b;
        take[i][j] = true;
      }
    }
  }
  int ax = minions[x].first.second;
  int bx = minions[x].first.first;
  return dp[n - 1][k - 1] + ax + (k - 1) * bx;
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  int T;
  cin >> T;
  while (T--) {
    int n, k;
    cin >> n >> k;
    for (int i = 1; i <= n; i++) {
      int a, b;
      cin >> a >> b;
      minions[i] = {{b, a}, i};
    }
    sort(minions + 1, minions + n + 1);
    int mx = -1, ind = 0;
    for (int i = 1; i <= n; i++) {
      int res = solve(i, n, k);
      if (res > mx) {
        mx = res;
        ind = i;
      }
    }
    solve(ind, n, k);
    for (int i = n - 1, j = k - 1; i >= 1; i--) {
      if (take[i][j]) {
        is_taken[i] = true;
        j--;
      } else
        is_taken[i] = false;
    }
    cout << 2 * n - k << "\n";
    for (int i = 1; i < n; i++) {
      if (is_taken[i]) cout << A[i].second << " ";
    }
    for (int i = 1; i < n; i++) {
      if (!is_taken[i]) cout << A[i].second << " " << -A[i].second << " ";
    }
    cout << minions[ind].second << "\n";
  }
  return 0;
}
