#include <bits/stdc++.h>
using namespace std;

#ifndef DEBUG
#define endl '\n'
#define debug(...)
#else
#define debug(...) __VA_ARGS__
#endif
#define debugf(...) debug(printf(__VA_ARGS__);)

const int oo = 0x3f3f3f3f;
const int N = 128;

int dp[N][N];
int pick[N][N];

struct Minion {
    int a, b, i;
};

pair<vector<int>, vector<int>> solve(vector<Minion>& minions, int k) {
    int n = minions.size();
    memset(dp, -oo, sizeof(dp));
    sort(minions.begin(), minions.end(), [&](const auto& x, const auto& y) {
        return x.b < y.b;
    });

    dp[0][0] = 0;

    for (int i = 1; i <= n; i++) {
        auto [a, b, _] = minions[i-1];
        dp[0][i] = (k - 1) * b;
        pick[0][i] = 0;
    }
    for (int i = 1; i <= n; i++) {
        for (int p = 1; p <= k; p++) {
            auto [a, b, _] = minions[i-1];
            int pickF = dp[p-1][i-1] + (p-1)*b + a;
            int pickU = dp[p][i-1] + (k-1)*b;

            // Maybe?
            if (dp[p-1][i-1] == -oo) pickF = -oo;
            if (dp[p][i-1] == -oo) pickU = -oo;

            if (pickF > pickU) {
                pick[p][i] = p-1;
                dp[p][i] = pickF;
            } else {
                pick[p][i] = p;
                dp[p][i] = pickU;
            }
        }
    }

    debugf("ans=%d\n", dp[k][n]);

    vector<int> f; f.reserve(k);
    vector<int> u; u.reserve(n - k);

    int p = k;
    for (int i = n; i >= 1; i--) {
        if (pick[p][i] == p-1) {
            f.emplace_back(minions[i-1].i);
        } else {
            u.emplace_back(minions[i-1].i);
        }

        p = pick[p][i];
    }

    assert(p == 0);

    reverse(f.begin(), f.end());
    return { f, u };
}

signed (((((main)))))() <%
    ios_base::sync_with_stdio(false);
    cin.tie(0); cout.tie(0);

    int t; cin >> t;
    while (t--) {
        int n, k;
        cin >> n >> k;

        vector<Minion> minions(n);
        for (int i = 1; i <= n; i++) {
            auto& [a, b, j] = minions[i-1];
            cin >> a >> b;
            j = i;
        }

        auto [f, u] = solve(minions, k);

        assert(f.size() + 2 * u.size() == k + 2 * (n - k));
        cout << f.size() + 2 * u.size() << endl;
        for (int i = 0; i < k-1; i++)
            cout << f[i] << ' ';
        for (int i : u)
            cout << i << ' ' << -i << ' ';
        cout << f.back() << endl;
    }

    return 0;
%>