#include <bits/stdc++.h>
using namespace std;
template<class F, class S>
ostream &operator<<(ostream &s, const pair<F, S> &v) {
s << "(" << v.first << ", " << v.second << ")";
return s;
}
template<ranges::range T> requires (!is_convertible_v<T, string_view>)
istream &operator>>(istream &s, T &&v) {
for (auto &&x : v) s >> x;
return s;
}
template<ranges::range T> requires (!is_convertible_v<T, string_view>)
ostream &operator<<(ostream &s, T &&v) {
for (auto &&x : v) s << x << ' ';
return s;
}
#ifdef LOCAL
template<class... T> void dbg(T... x) {
char e{};
((cerr << e << x, e = ' '), ...);
}
#define debug(x...) dbg(#x, '=', x, '\n')
#else
#define debug(...) ((void)0)
#endif
#define all(v) (v).begin(), (v).end()
#define rall(v) (v).rbegin(), (v).rend()
#define ff first
#define ss second
template<class T> inline constexpr T inf = numeric_limits<T>::max() / 2;
bool chmin(auto &a, auto b) { return (b < a and (a = b, true)); }
bool chmax(auto &a, auto b) { return (a < b and (a = b, true)); }
using u32 = unsigned int;
using i64 = long long;
using u64 = unsigned long long;
using i128 = __int128;
using u128 = unsigned __int128;
constexpr i64 mod = 998244353;
void solve() {
int n;
cin >> n;
vector<i64> A(n), B(n), C(n), D(n);
for (int i = 0; i < n; i++) {
cin >> A[i] >> B[i] >> C[i];
D[i] = A[i] - B[i];
}
const i64 Bsum = reduce(all(B), 0LL);
vector<pair<i64, i64>> pa(n);
vector<int> ord(n);
iota(all(ord), 0);
auto check = [&](i64 P) -> bool {
for (int i = 0; i < n; i++) {
pa[i] = {D[i], P / C[i] - B[i] - Bsum};
}
sort(all(ord), [&](int i, int j) {
return min(a.ss - a.ff, b.ss - a.ff - b.ff) > min(b.ss - b.ff, a.ss - a.ff - b.ff);
});
i64 sum = 0;
for (auto i : ord) {
auto [a, b] = pa[i];
sum += a;
if (sum > b) {
return false;
}
}
return true;
};
i64 ans = *ranges::partition_point(views::iota(0LL, (i64)1.1E18),
[&](i64 x) {
return !check(x);
});
assert(check(ans));
for (int x : ord) {
cout << x + 1 << " \n"[x == ord.back()];
}
}
signed main() {
cin.tie(0)->sync_with_stdio(0);
cin.exceptions(cin.failbit);
int t = 1;
cin >> t;
while (t--) {
solve();
}
return 0;
}