Matryoshka Dolls, Again

No attempts yetTime limit1sMemory limit128 MB

Problem

Adam has received yet another box of Matryoshka dolls from Matryona. This time the dolls come in all shapes and sizes. Each doll ii is described by three numbers: its width wiw_i, length lil_i, and height hih_i.

Doll ii can be placed inside doll jj if and only if wi<wjw_i < w_j, li<ljl_i < l_j, and hi<hjh_i < h_j all hold. In other words, every one of the three dimensions must be strictly smaller, and a doll may not be rotated when it is nested. Moreover, each doll can hold at most one other doll directly inside it.

Nest the dolls inside one another so that the number of outermost dolls is as small as possible, and report that minimum number.

Input

The input consists of several test cases. Each test case starts with a line containing a single integer NN, the number of dolls (1N5001 \le N \le 500). Each of the next NN lines contains three space-separated integers wiw_i, lil_i, and hih_i (1wi,li,hi10,0001 \le w_i, l_i, h_i \le 10{,}000), the dimensions of the ii-th doll.

The input ends with a line containing N=0N = 0, which must not be processed.

Output

For each test case, print on its own line the minimum possible number of outermost dolls after nesting the given dolls optimally.