#include<bits/stdc++.h>
using namespace std;
#define int long long
const int limit = 2000000010;
signed main(){
ios_base::sync_with_stdio(false);
cin.tie(0); cout.tie(0);
int n; cin >> n;
vector<array<int, 3>> a(n + 1);
for(int i = 1; i <= n; i++){
cin >> a[i][1] >> a[i][2] >> a[i][0];
a[i][1] += 1e9;
a[i][2] += 1e9;
}
vector<int> order(n + 1);
for(int i = 1; i <= n; i++) order[i] = i;
sort(order.begin() + 1, order.end(), [&](int i, int j){
return a[i][0] == a[j][0] ? i < j : a[i][0] > a[j][0];
});
auto check = [&](int i, int j){
return (a[i][1] - a[j][1]) * (a[i][1] - a[j][1]) + (a[i][2] - a[j][2]) * (a[i][2] - a[j][2]) <= (a[i][0] + a[j][0]) * (a[i][0] + a[j][0]);
};
int sz = 2000000000;
map<int, vector<int>> mp;
vector<int> ans(n + 1);
for(int i = 1; i <= n; i++){
if(ans[order[i]]) continue;
bool ok = false;
while(sz / 2 >= a[order[i]][0]){
sz /= 2;
ok = 1;
}
ans[order[i]] = order[i];
if(ok){
mp.clear();
for(int j = 1; j <= n; j++){
if(!ans[j]) mp[(a[j][1] / sz) * limit + a[j][2] / sz].push_back(j);
}
}
int x = a[order[i]][1] / sz, y = a[order[i]][2] / sz;
for(int j = x - 2; j <= x + 2; j++){
for(int k = y - 2; k <= y + 2; k++){
int id = j * limit + k;
for(int c: mp[id]){
if(check(c, order[i]) && !ans[c]) ans[c] = order[i];
}
}
}
}
for(int i = 1; i <= n; i++) cout << ans[i] << " ";
}