#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <cstring>
#include <sstream>
#include <map>
#include <set>
#include <cmath>
#include <queue>
#include <stack>
#include <list>
#include <numeric>
#include <bitset>
#include <ext/algorithm>
#include <ext/numeric>
#define ffor(_a,_f,_t) for(int _a=(_f),__t=(_t);_a<__t;_a++)
#define all(_v) (_v).begin() , (_v).end()
#define SZ(x) ((int)(x).size())
#define pb push_back
#define eb emplace_back
#define SET(__set, val) memset(__set, val, sizeof(__set))
#define FOR(__i, __n) ffor (__i, 0, __n)
typedef long long LL; using namespace std;

vector<vector<int>> BA;

int n, k;

LL dp[100][100];
int path[100][100];

void update(LL &ret, LL tmp, int summoned, int idx, bool have) {
	if (tmp > ret) {
		ret = tmp;
		path[summoned][idx] = have;
	}
}

LL memo(int summoned, int idx) {
	if (idx == n) {
		if (summoned < k)
			return -(1LL << 50LL);
		return 0LL;
	}
		
		
	LL &ret = dp[summoned][idx];
	if (ret != -1)
		return ret;
		
	ret = 0LL;
		
	LL tmp;
	if (summoned < k)
		update(ret, BA[idx][1] + (1LL * summoned * BA[idx][0]) + memo(summoned + 1, idx + 1),
			summoned, idx, true);
	
	update(ret, (k - 1) * BA[idx][0] + memo(summoned, idx + 1),
		summoned, idx, false);
	return ret;
}

int main() {
	std::ios::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(0);
	
	int _;
	cin >> _;
	while (_--) {
		cin >> n >> k;
		BA.resize(n);
		int x, y;
		FOR (i, n) {
			cin >> x >> y;
			BA[i] = {y, x, i};
		}
		sort(all(BA));
			
		SET(dp, 255);
		LL ret = memo(0, 0);
		
		// recover
		int summoned = 0;
		vector<int> takeThem;
		bool marked[100];
		SET(marked, 0);
		FOR (i, n) {
			if (path[summoned][i]) {
				takeThem.pb(BA[i][2]);
				summoned++;
				marked[BA[i][2]] = true;
			}
		}
		
		cout << k + 2 * (n - k) << endl;
		FOR (i, SZ(takeThem) - 1)
			cout << takeThem[i]+1 << " ";
		FOR (i, n)
			if (!marked[i]) {
				cout << i+1 << " -" << i+1 << " ";
			}
		cout << takeThem[SZ(takeThem) - 1]+1 << endl;
	}
	
	return 0;
}
