#include <algorithm>
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const int MAXN = 303030;
struct Circle {
int x, y, r, id;
bool doesIntersect(const Circle& rhs) const {
ll dx = x - rhs.x;
ll dy = y - rhs.y;
ll pr = r + rhs.r;
return dx * dx + dy * dy <= pr * pr;
}
};
int n, a[MAXN];
Circle cx[MAXN];
int main()
{
ios_base::sync_with_stdio(false); cin.tie(NULL);
cin >> n;
for(int i = 1; i <= n; i++) {
cin >> cx[i].x >> cx[i].y >> cx[i].r; cx[i].id = i;
}
// vector<Circle> xorder;
// for(int i = 1; i <= n; i++) xorder.push_back(cx[i]);
// sort(xorder.begin(), xorder.end(), [](const Circle& a, const Circle& b) { return a.x < b.x; });
auto rescale = [&](int R) -> map<pair<int, int>, vector<Circle>> {
map<pair<int, int>, vector<Circle>> res;
for(int i = 1; i <= n; i++) {
if(a[i]) continue;
int r = cx[i].x / R;
int c = cx[i].y / R;
res[{r, c}].push_back(cx[i]);
}
return res;
// vector<Circle> tmp;
// for(auto c : xorder) if(a[c.id] == 0) tmp.push_back(c);
// xorder = tmp;
// vector<int> pos;
// vector<vector<Circle>> res;
// for(int i = 0; i < xorder.size();) {
// int j = i;
// vector<Circle> block;
// while(j < xorder.size() && xorder[j].x - xorder[i].x < R) {
// block.push_back(xorder[j]);
// j++;
// }
// sort(block.begin(), block.end(), [](const Circle& a, const Circle& b){
// return a.y < b.y;
// });
// pos.push_back(xorder[i].x);
// res.push_back(block);
// i = j;
// }
// return {pos, res};
};
int R = 1e9;
vector<int> v(n);
iota(v.begin(), v.end(), 1);
sort(v.begin(), v.end(), [](int i, int j) { return tuple(-cx[i].r, i) < tuple(-cx[j].r, j); });
// auto [pos, table] = rescale(R);
auto table = rescale(R);
for(auto i : v) {
if(a[i]) continue;
a[i] = i;
int oldR = R;
while(R/2 >= cx[i].r) R /= 2;
if(oldR != R) table = rescale(R);
int r = cx[i].x / R;
int c = cx[i].y / R;
for(int dr = -2; dr <= 2; dr++) {
for(int dc = -2; dc <= 2; dc++) {
for(auto c : table[{r+dr, c+dc}]) {
if(a[c.id]) continue;
if(cx[i].doesIntersect(c)) a[c.id] = i;
}
}
}
// int sx = upper_bound(pos.begin(), pos.end(), cx[i].x-2*cx[i].r) - pos.begin() - 1;
// sx = max(sx, 0);
// for(int j = sx; j < pos.size(); j++) {
// if(pos[j] > cx[i].x+2*cx[i].r) break;
// auto& t = table[j];
// int sy = upper_bound(t.begin(), t.end(), cx[i].y-2*cx[i].r, [](int x, const Circle& c){
// return x < c.y;
// }) - t.begin() - 1;
// sy = max(sy, 0);
// for(int k = sy; k < t.size(); k++) {
// auto c = t[k];
// if(c.y > cx[i].y+2*cx[i].r) break;
// if(a[c.id] == 0 && cx[i].doesIntersect(c)) {
// a[c.id] = i;
// }
// }
// }
}
for(int i = 1; i <= n; i++) cout << a[i] << " ";
}