#include <bits/stdc++.h>
using namespace std;
const long long maxn = 1e6 + 10;
long long n, m, q;
long long da[maxn], db[maxn];
inline long long read() {
  long long X = 0, w = 0;
  char ch = 0;
  while (!isdigit(ch)) w |= ch == '-', ch = getchar();
  while (isdigit(ch)) X = (X << 3) + (X << 1) + (ch ^ 48), ch = getchar();
  return w ? -X : X;
}
bool cmp(long long a, long long b) {
  return da[a] + db[b] * (m - 1) > da[b] + db[a] * (m - 1);
}
signed main() {
  long long t = read();
  while (t--) {
    vector<long long> cz, nc;
    long long n = read(), m = read();
    long long idx[100];
    for (long long i = 0; i < n; i++) {
      da[i] = read();
      db[i] = read();
    }
    long long res = 0;
    for (long long k = 0; k < n; k++) {
      long long cnt = 0;
      long long tot = 0;
      nc.clear();
      for (long long i = 0; i < n; i++) {
        if (i != k) idx[tot++] = i;
      }
      sort(idx, idx + n - 1, cmp);
      for (long long u = 0; u < n - 1; u++) {
        long long i = idx[u];
        if (u < m - 1) {
          nc.push_back(i + 1);
          cnt += da[i];
        } else {
          nc.push_back(i + 1);
          nc.push_back(-i - 1);
          cnt += db[i] * (m - 1);
        }
      }
      nc.push_back(k + 1);
      cnt += da[k] + db[k] * (m - 1);
      if (cnt > res) {
        res = cnt;
        cz = nc;
      }
    }
    cout << cz.size() << endl;
    for (auto i : cz) cout << i << ' ';
    cout << endl;
  }
  return 0;
}
