Let us define a partial order on triples \mathbf{a} = (x_a, y_a, z_a) and \mathbf{b} = (x_b, y_b, z_b) as follows:
\mathbf{a} \prec \mathbf{b} if x_a < x_b, y_a < y_b, and z_a < z_b.
Given a set of triples, find the length of the longest strictly increasing sequence of triples \mathbf{a}_1 \prec \mathbf{a}_2 \prec \dotsb \prec \mathbf{a}_k.

The input consists of several datasets. Each dataset describes a set of triples in the following format:
m~n~A~B
x_1~y_1~z_1
x_2~y_2~z_2
x_m~y_m~z_m
The first line contains four integers: , , , . All values x_i, y_i, z_i (1 \le i \le m) are non-negative integers.
Each dataset contains m + n triples. The first triples, \mathbf{p}_1 through \mathbf{p}_m, are given explicitly (\mathbf{p}_i = (x_i, y_i, z_i)). The remaining triples are generated as follows, using parameters and :
int a = A, b = B, C = ~(1<<31), M = (1<<16)-1;
int r() {
a = 36969 * (a & M) + (a >> 16);
b = 18000 * (b & M) + (b >> 16);
return (C & ((a << 16) + b)) % 1000000;
}Call a total of times to generate, in order:
You may assume:
The input ends with a line containing four zeros.
The total sum of m+n over all datasets does not exceed 2 \times 10^6.
For each dataset, output the length of the longest strictly increasing sequence of triples in the given set—that is, the largest such that \mathbf{p}_{i_1} \prec \mathbf{p}_{i_2} \prec \dotsb \prec \mathbf{p}_{i_k}.
Example 1