#!/usr/bin/env python3.8 import sys read = sys.stdin.buffer.read readline = sys.stdin.buffer.readline readlines = sys.stdin.buffer.readlines import numpy as np N = int(readline()) PTR = np.array(read().split(), np.int64) P = PTR[::3] T = PTR[1::3] R = PTR[2::3] INF = 10 ** 4 + 100 dp = np.zeros((10001, 10001), np.int32) for p, t, r in zip(P.tolist(), T.tolist(), R.tolist()): if dp[p, t] < r: dp[p, t] = r if p: if dp[p - 1, t] < r + 1: dp[p - 1, t] = r + 1 if t: if dp[p, t - 1] < r + 1: dp[p, t - 1] = r + 1 dp = dp[::-1, ::-1] np.maximum.accumulate(dp, axis=0, out=dp) np.maximum.accumulate(dp, axis=1, out=dp) dp = dp[::-1, ::-1] ok = dp[P, T] <= R print('\n'.join((ok + 1).astype(str)))