#include <bits/stdc++.h>

using namespace std;
using int64    = long long;
using PII      = pair<int, int>;
const int MAXN = 100005;
const int INF  = 0x3f3f3f3f;

vector<int> a[MAXN];

int main() {
#ifdef LOCAL
    freopen("in.txt", "r", stdin);
#endif
    int t;
    cin >> t;
    while(t--) {
        int n,k;
        cin >> n >> k;
        int x,y;
        for(int i=1;i<=n;i++) {
            cin >> x >> y;
            a[i] = {x,y,i};
        }
        sort(a+1,a+n+1,[&](auto& x, auto& y) { return x[0]==y[0]?x[1]<y[1]:x[0]>y[0]; });
        sort(a+1,a+k,[&](auto& x, auto& y) { return x[1] < y[1]; });
        for(int i=1;i<k;i++) cout << a[i][2] << " ";
        sort(a+k+1,a+n+1,[&](auto& x, auto& y) { return x[1]<y[1]; });
        for(int i=k+1;i<=n;i++) cout << a[i][2] << " " << -a[i][2] << " ";
        cout << a[k][2] << endl;
        
    }
}
