#include <bits/stdc++.h>
#pragma GCC optimize(2)
const double esp = 1e-6;
const double pi = acos(-1.0);
const int INF = 0x3f3f3f3f;
const int inf = 1e9;
using namespace std;
long long read() {
  char ch = getchar();
  long long x = 0, f = 1;
  while (ch < '0' || ch > '9') {
    if (ch == '-') f = -1;
    ch = getchar();
  }
  while (ch >= '0' && ch <= '9') {
    x = x * 10 + ch - '0';
    ch = getchar();
  }
  return x * f;
}
const int N = 110;
int T, n, k;
struct node {
  long long a, b;
  int id;
  bool operator<(const node temp) const { return b < temp.b; }
} nd[N];
long long dp[N][N];
int pre[N][N];
int main() {
  T = read();
  while (T--) {
    n = read(), k = read();
    for (int i = 0; i <= n; i++)
      for (int j = 0; j <= k; j++) dp[i][j] = -1e18;
    for (int i = 1; i <= n; i++) {
      nd[i].a = read(), nd[i].b = read();
      nd[i].id = i;
    }
    sort(nd + 1, nd + n + 1);
    dp[0][0] = 0;
    for (int i = 1; i <= n; i++) {
      for (int j = 1; j <= k; j++) {
        if (j > i) break;
        dp[i][j] = dp[i - 1][j - 1] + nd[i].a + (j - 1) * nd[i].b;
        pre[i][j] = j - 1;
        if (dp[i - 1][j] >= 0) {
          long long temp = dp[i - 1][j] + (k - 1) * nd[i].b;
          if (temp > dp[i][j]) {
            dp[i][j] = temp;
            pre[i][j] = j;
          }
        }
      }
    }
    vector<int> ans;
    vector<int> ans2;
    int kk = k;
    for (int i = n; i >= 1; i--) {
      if (pre[i][kk] == kk) {
        ans2.push_back(-nd[i].id);
        ans2.push_back(nd[i].id);
      } else {
        ans.push_back(nd[i].id);
        kk = pre[i][kk];
      }
    }
    reverse(ans.begin(), ans.end());
    reverse(ans2.begin(), ans2.end());
    cout << ans.size() + ans2.size() << endl;
    for (int i = 0; i < ans.size() - 1; i++) {
      printf("%d ", ans[i]);
    }
    for (auto k : ans2) printf("%d ", k);
    printf("%d\n", ans.back());
  }
}
