#include <bits/stdc++.h>
using namespace std;
int a[76], b[76];
pair<pair<int, int>, int> p[76];
long long dp[76][76];
bool vis[76][76];
int pv1[76][76], pv2[76][76];
bool ok[76];
int main() {
  int t;
  scanf("%d", &t);
  while (t--) {
    int n, k;
    scanf("%d%d", &n, &k);
    long long sum = 0;
    for (int i = 1; i <= n; i++)
      scanf("%d%d", &a[i], &b[i]),
          p[i] = pair<pair<int, int>, int>(pair<int, int>(b[i], a[i]), i),
          sum += b[i];
    sort(p + 1, p + 1 + n);
    if (k == 1) {
      int idx = 1;
      for (int i = 1; i <= n; i++) {
        if (a[i] > a[idx]) idx = i;
      }
      printf("1\n%d\n", idx);
      continue;
    }
    memset(vis, 0, sizeof(vis));
    dp[0][0] = 0;
    vis[0][0] = 1;
    for (int i = 1; i <= n; i++) {
      int a = p[i].first.second, b = p[i].first.first, idx = p[i].second;
      for (int j = k - 1; j >= 0; j--) {
        if (!vis[i - 1][j]) continue;
        if (!vis[i][j] || dp[i][j] < dp[i - 1][j]) {
          dp[i][j] = dp[i - 1][j];
          pv1[i][j] = j;
          vis[i][j] = 1;
        }
        if (j == k - 1) {
          long long cost = a;
          if (!vis[i][j + 1] || dp[i][j] < dp[i - 1][j] + cost) {
            dp[i][j + 1] = dp[i - 1][j] + cost;
            pv1[i][j + 1] = j;
            pv2[i][j + 1] = idx;
            vis[i][j + 1] = 1;
          }
        } else {
          long long cost = a + sum - (k - 1 - j) * 1ll * b;
          if (!vis[i][j + 1] || dp[i][j] < dp[i - 1][j] + cost) {
            dp[i][j + 1] = dp[i - 1][j] + cost;
            pv1[i][j + 1] = j;
            pv2[i][j + 1] = idx;
            vis[i][j + 1] = 1;
          }
        }
      }
    }
    int cur = k;
    vector<int> ans;
    for (int i = n; i >= 1; i--) {
      if (pv1[i][cur] == cur)
        continue;
      else {
        ans.emplace_back(pv2[i][cur]);
        cur = pv1[i][cur];
      }
    }
    reverse(ans.begin(), ans.end());
    memset(ok, 0, sizeof(ok));
    for (int i = 0; i < (int)ans.size(); i++) ok[ans[i]] = 1;
    vector<int> res;
    for (int i = 0; i < (int)ans.size() - 1; i++) res.emplace_back(ans[i]);
    for (int i = 1; i <= n; i++) {
      if (!ok[i]) {
        res.emplace_back(i);
        res.emplace_back(-i);
      }
    }
    res.emplace_back(ans[ans.size() - 1]);
    printf("%d\n", res.size());
    for (int i = 0; i < res.size(); i++) printf("%d ", res[i]);
    printf("\n");
  }
}
