Every vector has a direction, and two vectors determine one angle between them. Given a set of three-dimensional vectors, find the pair among them that makes the smallest angle.
The input is a sequence of datasets. One dataset specifies one set of three-dimensional vectors. Some of the vectors are written in the dataset directly and the rest are produced by the procedure below.
Each dataset has the following format.
m n S W
x1 y1 z1
x2 y2 z2
.
.
.
xm ym zm
The first line has four integers m, n, S, and W.
m is the number of vectors whose three components are written in the dataset directly. The next m lines hold those components, and the i-th of them means the vector vi=(xi,yi,zi). Every vector component is a positive integer at most 100.
n is the number of vectors produced by the following procedure.
int g = S;
for (int i = m + 1; i <= m + n; i++) {
x[i] = (g / 7) % 100 + 1;
y[i] = (g / 700) % 100 + 1;
z[i] = (g / 70000) % 100 + 1;
if (g % 2 == 0) { g = (g / 2); }
else { g = (g / 2) ^ W; }
}
For i=m+1,…,m+n, the three components of the i-th vector vi of the set are the values x[i], y[i], and z[i] that this procedure computes.
S and W are the values given on the first line of the dataset, and 1≤S≤109, 1≤W≤109.
The total number of vectors satisfies 2≤m+n≤12×104. The same vector may be specified twice or more in a single dataset.
A line containing four zeros indicates the end of the input. The total of m+n over all datasets in the input never exceeds 16×105.
For each dataset, print on one line the two vectors of the given set whose angle is the smallest among all nonzero angles. At least two vectors have different directions.
A vector is written by its three components. Print a pair of vectors va and vb in this format.
xa ya za xb yb zb
Two vectors (xa,ya,za) and (xb,yb,zb) compare in dictionary order, that is, va<vb if xa<xb, or if xa=xb and ya<yb, or if xa=xb, ya=yb and za<zb. When you print a pair, print the smaller vector in this order first.
If more than one pair makes the equal smallest angle, print the pair that is the smallest among them in the dictionary order between vector pairs. The pair (vi,vj) is smaller than the pair (vk,vl) if vi<vk, or if vi=vk and vj<vl.