#include <bits/stdc++.h>
using namespace std;
int test, n, k, a[88], b[88], path[88][88], x, y, ap[88], ans[888], cnt, sz, nt;
vector<int> v;
long long dp[88][88], mx, cc;
pair<pair<int, int>, int> arr[88];
int main() {
  scanf("%d", &test);
  while (test--) {
    scanf("%d%d", &n, &k);
    for (int i = 1; i <= n; i++) {
      scanf("%d%d", &a[i], &b[i]);
      arr[i] = make_pair(make_pair(b[i], a[i]), i);
    }
    sort(arr + 1, arr + n + 1);
    mx = -1e18;
    for (int t = 1; t <= n; t++) {
      for (int i = 0; i <= n; i++) {
        for (int j = 0; j <= k; j++) dp[i][j] = -1e18;
      }
      dp[0][0] = 0;
      for (int i = 0; i < n; i++) {
        for (int j = 0; j < k; j++) {
          if (i + 1 == t) {
            dp[i + 1][j] = dp[i][j];
            continue;
          }
          if (dp[i + 1][j] < dp[i][j] + 1ll * j * arr[i + 1].first.first) {
            dp[i + 1][j] = dp[i][j] + 1ll * j * arr[i + 1].first.first;
            path[i + 1][j] = 0;
          }
          if (dp[i + 1][j + 1] < dp[i][j] + 1ll * j * arr[i + 1].first.first +
                                     arr[i + 1].first.second) {
            dp[i + 1][j + 1] = dp[i][j] + 1ll * j * arr[i + 1].first.first +
                               arr[i + 1].first.second;
            path[i + 1][j + 1] = 1;
          }
        }
      }
      cc = dp[n][k - 1] + 1ll * (k - 1) * arr[t].first.first +
           arr[t].first.second;
      if (cc > mx) {
        mx = cc;
        nt = t;
      }
    }
    memset(path, 0, sizeof(path));
    memset(ap, 0, sizeof(ap));
    cnt = 0;
    for (int i = 0; i <= n; i++) {
      for (int j = 0; j <= k; j++) dp[i][j] = -1e18;
    }
    dp[0][0] = 0;
    for (int i = 0; i < n; i++) {
      for (int j = 0; j < k; j++) {
        if (i + 1 == nt) {
          dp[i + 1][j] = dp[i][j];
          continue;
        }
        if (dp[i + 1][j] < dp[i][j] + 1ll * j * arr[i + 1].first.first) {
          dp[i + 1][j] = dp[i][j] + 1ll * j * arr[i + 1].first.first;
          path[i + 1][j] = 0;
        }
        if (dp[i + 1][j + 1] < dp[i][j] + 1ll * j * arr[i + 1].first.first +
                                   arr[i + 1].first.second) {
          dp[i + 1][j + 1] = dp[i][j] + 1ll * j * arr[i + 1].first.first +
                             arr[i + 1].first.second;
          path[i + 1][j + 1] = 1;
        }
      }
    }
    x = n;
    y = k - 1;
    while (x >= 1) {
      if (x == nt) {
        x--;
        continue;
      }
      ap[x] = y;
      y -= path[x][y];
      x--;
    }
    cnt = 0;
    y = 0;
    v.clear();
    sz = 0;
    for (int i = 1; i <= n; i++) {
      if (i == nt) continue;
      if (ap[i] == y + 1) {
        if (sz < k) {
          ans[++cnt] = arr[i].second;
          sz++;
        } else {
          ans[++cnt] = -v.back();
          v.pop_back();
          ans[++cnt] = arr[i].second;
        }
      } else {
        if (sz < k) {
          ans[++cnt] = arr[i].second;
          sz++;
          v.push_back(arr[i].second);
        } else {
          ans[++cnt] = -v.back();
          v.pop_back();
          ans[++cnt] = arr[i].second;
          v.push_back(arr[i].second);
        }
      }
      y = ap[i];
    }
    for (int i = 0; i < v.size(); i++) {
      ans[++cnt] = -v[i];
    }
    ans[++cnt] = arr[nt].second;
    printf("%d\n", cnt);
    for (int i = 1; i <= cnt; i++) printf("%d ", ans[i]);
    printf("\n");
  }
  return 0;
}
