#include <bits/stdc++.h>
using namespace std;
const int N = 77, inf = -1e9;
int n, k, t, dp[N][N], par[N][N], mark[N];
pair<int, pair<int, int> > a[N];
int main() {
  cin >> t;
  for (int q = 0; q < t; q++) {
    fill(mark, mark + N, 0);
    cin >> n >> k;
    for (int i = 1; i < n + 1; i++) {
      cin >> a[i].second.first >> a[i].first;
      a[i].second.second = i;
    };
    sort(a + 1, a + n + 1);
    for (int i = 1; i < n + 1; i++) dp[0][i] = inf;
    for (int i = 1; i < n + 1; i++) {
      dp[i][0] = dp[i - 1][0] + a[i].first * (k - 1);
      for (int j = 1; j < k + 1; j++) {
        dp[i][j] = dp[i - 1][j] + a[i].first * (k - 1);
        if (dp[i][j] <
            dp[i - 1][j - 1] + a[i].second.first + a[i].first * (j - 1))
          dp[i][j] =
              dp[i - 1][j - 1] + a[i].second.first + a[i].first * (j - 1),
          par[i][j] = 1;
      }
    }
    cout << n * 2 - k << endl;
    int now = k;
    for (int i = n; i >= 1; i--) {
      if (par[i][now]) mark[i] = 1, now--;
    }
    for (int i = 1; i < n + 1; i++) {
      if (mark[i] && k > 1) {
        k--;
        cout << a[i].second.second << " ";
      }
    }
    for (int i = 1; i < n + 1; i++)
      if (!mark[i])
        cout << a[i].second.second << " " << -a[i].second.second << " ";
    for (int i = n; i >= 1; i--)
      if (mark[i]) {
        cout << a[i].second.second << endl;
        break;
      }
  }
}
