#include <bits/stdc++.h>
using namespace std;
struct work {
  int l, r, t, id;
};
int inf = (int)2e9;
struct node {
  int to_min, to_sub;
  node() { to_min = to_sub = 0; }
};
struct MTree {
  vector<node> tree;
  int st, d;
  MTree(int n) {
    st = 1;
    d = 0;
    while (st < n) {
      st *= 2;
      d++;
    }
    tree.resize(st * 2);
    for (int i = 0; i < (int)tree.size(); i++) {
      tree[i].to_min = inf;
    }
  }
  void flush(int v) {
    if (tree[v].to_min != inf) {
      tree[v].to_min -= tree[v].to_sub;
    }
    tree[v].to_sub = 0;
  }
  inline void fix(int v) {
    if (tree[v].to_sub) {
      if (v < st) {
        int l = v * 2, r = l + 1;
        tree[l].to_sub += tree[v].to_sub;
        tree[r].to_sub += tree[v].to_sub;
      }
      flush(v);
    }
  }
  void recalc(int v) {
    int l = v * 2, r = l + 1;
    tree[v].to_min = min(tree[l].to_min, tree[r].to_min);
  }
  void fix_down(int i) {
    int v = 1, x = d - 1;
    while (v != i) {
      int f = (i >> x) & 1;
      x--;
      fix(v);
      v = v * 2 + f;
    }
    fix(v);
  }
  void go(int v, int vl, int vr, int l, int r, int x) {
    if (r < vl || vr < l) {
      fix(v);
      return;
    }
    if (l <= vl && vr <= r) {
      tree[v].to_sub += x;
      fix(v);
      return;
    }
    int nl = v * 2, nr = nl + 1, vc = (vl + vr) / 2;
    go(nl, vl, vc, l, r, x);
    go(nr, vc + 1, vr, l, r, x);
    recalc(v);
  }
  void sub(int l, int r, int x) { go(1, 0, st - 1, l, r, x); }
  int get(int v, int vl, int vr, int l, int r) {
    if (r < vl || vr < l) {
      return inf;
    }
    fix(v);
    if (l <= vl && vr <= r) {
      return tree[v].to_min;
    }
    int nl = v * 2, nr = nl + 1, vc = (vl + vr) / 2;
    int a = get(nl, vl, vc, l, r), b = get(nr, vc + 1, vr, l, r);
    return min(a, b);
  }
  int get(int l, int r) { return get(1, 0, st - 1, l, r); }
  int &operator[](int i) {
    i += st;
    fix_down(i);
    return tree[i].to_min;
  }
  void fix_up(int v) {
    v += st;
    while (v != 1) {
      int u = v ^ 1;
      fix(u);
      v /= 2;
      recalc(v);
    }
  }
};
int reset(MTree &D, MTree &T, int e, int j, const work &work_j) {
  int ne = max(e, work_j.l) + work_j.t;
  D[j] = ne - work_j.t - work_j.l;
  D.fix_up(j);
  T[j + 1] = -work_j.t;
  T.fix_up(j + 1);
  return ne;
}
int main(void) {
  int work_n;
  scanf("%d", &work_n);
  vector<work> works(work_n + 1);
  for (int i = 1; i <= work_n; i++) {
    scanf("%d %d %d", &works[i].l, &works[i].r, &works[i].t);
    works[i].r++;
    works[i].id = i;
  }
  vector<int> ids(work_n + 1);
  int res_i = 0;
  MTree T(work_n + 2), D(work_n + 2);
  works[0].l = 0;
  works[0].r = inf;
  works[0].t = 0;
  D[0] = 0;
  D.fix_up(0);
  T[1] = 0;
  T.fix_up(1);
  for (int i = 1; i <= work_n; i++) {
    ids[res_i + 1] = works[i].id;
    int old_ans = D[res_i] + works[ids[res_i]].l + works[ids[res_i]].t;
    int x_ans = reset(D, T, old_ans, res_i + 1, works[i]);
    if (x_ans <= works[i].r) {
      res_i++;
      printf("0 ");
      continue;
    }
    int best_j = -1, best_sub = 0;
    {
      int v = 1;
      int cur_min = inf, cur_max = 0;
      D.fix(v);
      while (v < T.st) {
        int r = v * 2 + 1;
        D.fix(r);
        int new_min = min(D.tree[r].to_min, cur_min),
            new_max = max(-T.tree[r].to_min, cur_max);
        if (new_min <= new_max) {
          v = r;
        } else {
          cur_min = new_min;
          cur_max = new_max;
          v = r - 1;
          D.fix(v);
        }
      }
      cur_min = min(D.tree[v].to_min, cur_min);
      cur_max = max(-T.tree[v].to_min, cur_max);
      v -= T.st;
      int cur = min(cur_min, cur_max);
      if (v > 1) {
        best_sub = cur;
        best_j = v - 1;
      }
      v++;
      if (v <= res_i + 1) {
        int need_x = T.get(v, res_i + 1) + 1;
        int v = 1;
        while (v < T.st) {
          v *= 2;
          if (T.tree[v + 1].to_min < need_x) {
            v++;
          }
        }
        v -= T.st;
        cur = min(D.get(v, res_i + 1), -need_x + 1);
        if (cur >= best_sub) {
          best_sub = cur;
          best_j = v - 1;
        }
      }
    }
    if (x_ans - best_sub >= old_ans) {
      printf("-1 ");
    } else {
      res_i++;
      printf("%d ", ids[best_j]);
      int prev_e =
          D[best_j - 1] + works[ids[best_j - 1]].l + works[ids[best_j - 1]].t;
      reset(D, T, prev_e, best_j, works[0]);
      D.sub(best_j + 1, res_i, best_sub);
    }
  }
  return 0;
}
