#include <bits/stdc++.h>
using namespace std;
const int INF = 0x3f3f3f3f;
const int N = 110;
int f[N][N];
struct node {
  int a, b, id;
};
node arr[N];
bool st[N];
bool last[N][N];
bool cmp(node a, node b) { return a.b < b.b; }
int main() {
  int T;
  cin >> T;
  while (T--) {
    int n, m;
    cin >> n >> m;
    for (int i = 1; i <= n; i++) {
      cin >> arr[i].a >> arr[i].b;
      arr[i].id = i;
    }
    sort(arr + 1, arr + n + 1, cmp);
    memset(f, -0x3f, sizeof f);
    memset(st, 0, sizeof st);
    memset(last, 0, sizeof last);
    for (int i = 1; i <= n; i++) {
      f[i][0] = 0;
      for (int j = 0; j <= m && j <= i; j++) {
        if (f[i - 1][j] != -INF) {
          f[i][j] = f[i - 1][j] + (m - 1) * arr[i].b;
        }
        if (j > 0) {
          if (f[i - 1][j - 1] != -INF)
            if (f[i][j] < f[i - 1][j - 1] + (j - 1) * arr[i].b + arr[i].a) {
              f[i][j] = f[i - 1][j - 1] + (j - 1) * arr[i].b + arr[i].a;
              last[i][j] = 1;
            }
        }
      }
    }
    for (int i = n, j = m; i >= 1; i--) {
      if (last[i][j] == 1) {
        st[arr[i].id] = true;
        j--;
      }
    }
    cout << (m - 1) + 2 * (n - m) + 1 << endl;
    int num = 0;
    for (int i = 1; i <= n; i++) {
      if (st[i]) {
        num++;
        if (num == m) {
          num = arr[i].id;
          break;
        }
        cout << i << ' ';
      }
    }
    for (int i = 1; i <= n; i++) {
      if (!st[i]) {
        cout << i << ' ' << -i << ' ';
      }
    }
    cout << num << endl;
  }
}
