#include <bits/stdc++.h>
using namespace std;
struct elem {
  int l, p, t, ind;
  elem() {}
  elem(int inl, int inp, int intt, int inind) {
    l = inl;
    p = inp;
    t = intt;
    ind = inind;
  }
};
int base = 315;
int n;
elem v[1000000];
int btmax[1000000];
int bttope[1000000];
int cuantos[1000000];
int bdesp[1000000];
void recalcula(int b) {
  int ini = b * base;
  int fin = ini + cuantos[b] - 1;
  int& tmax = btmax[b];
  int& ttope = bttope[b];
  int& desp = bdesp[b];
  for (int i = ini; i <= fin; i++) v[i].p -= desp;
  tmax = 0;
  ttope = 2000000000;
  desp = 0;
  for (int i = fin; i >= ini; i--) {
    tmax = max(tmax, min(v[i].t, ttope));
    ttope = min(ttope, v[i].p - v[i].l);
  }
}
int ianterior(int b) {
  for (; b >= 0; b--)
    if (cuantos[b]) return base * b + cuantos[b] - 1;
  return -1;
}
void elimina(int b, int ttope, int iultimo) {
  recalcula(b);
  int ini = b * base;
  int fin = ini + cuantos[b] - 1;
  int tmax = 0, imax;
  for (int i = fin; i >= ini and tmax < ttope; i--) {
    if (v[i].t > tmax) {
      tmax = min(v[i].t, ttope);
      imax = i;
    }
    ttope = min(ttope, v[i].p - v[i].l);
  }
  if (imax == iultimo)
    cout << -1 << endl;
  else
    cout << v[imax].ind << endl;
  for (int i = imax; i < fin; i++) {
    v[i] = v[i + 1];
    v[i].p -= tmax;
  }
  cuantos[b]--;
  recalcula(b);
  int bultimo = iultimo / base;
  b++;
  for (; b <= bultimo; b++) {
    bdesp[b] += tmax;
    if (btmax[b] >= bttope[b] - bdesp[b]) recalcula(b);
  }
  recalcula(bultimo);
}
void elimina(int iultimo) {
  int b = iultimo / base;
  int tmax = 0, ttope = 2000000000, bmax;
  for (; b >= 0; b--) {
    if (max(tmax, btmax[b]) >= min(ttope, bttope[b] - bdesp[b])) {
      if (btmax[b] > tmax) {
        elimina(b, ttope, iultimo);
        return;
      }
      elimina(bmax, 2000000000, iultimo);
      return;
    }
    if (btmax[b] > tmax) {
      tmax = btmax[b];
      bmax = b;
    }
    ttope = min(ttope, bttope[b] - bdesp[b]);
  }
  elimina(bmax, 2000000000, iultimo);
}
int main() {
  ios::sync_with_stdio(false);
  cin >> n;
  for (int i = 1; i <= n; i++) {
    int l, r, t;
    cin >> l >> r >> t;
    if (i == 1) {
      cout << 0 << endl;
      v[0] = elem(l, l, t, i);
      cuantos[0]++;
      recalcula(0);
    } else {
      int b = (i - 1) / base;
      int iultimo, iant;
      if (cuantos[b]) {
        iant = b * base + cuantos[b] - 1;
        iultimo = iant + 1;
      } else {
        iant = ianterior(b - 1);
        iultimo = b * base;
      }
      v[iultimo] =
          elem(l, max(l, v[iant].p - bdesp[iant / base] + v[iant].t), t, i);
      cuantos[b]++;
      recalcula(b);
      if (v[iultimo].p + t - 1 <= r) {
        cout << 0 << endl;
      } else {
        elimina(iultimo);
      }
    }
  }
}
