Directional Resemblance

No attempts yetTime limit10sMemory limit128 MB

Problem

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.

Input

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 mm, nn, SS, and WW.

mm is the number of vectors whose three components are written in the dataset directly. The next mm lines hold those components, and the ii-th of them means the vector vi=(xi,yi,zi)v_i = (x_i, y_i, z_i). Every vector component is a positive integer at most 100100.

nn 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+ni = m + 1, \dots, m + n, the three components of the ii-th vector viv_i of the set are the values x[i]x[i], y[i]y[i], and z[i]z[i] that this procedure computes.

SS and WW are the values given on the first line of the dataset, and 1S1091 \le S \le 10^9, 1W1091 \le W \le 10^9.

The total number of vectors satisfies 2m+n12×1042 \le m + n \le 12 \times 10^4. 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+nm + n over all datasets in the input never exceeds 16×10516 \times 10^5.

Output

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 vav_a and vbv_b in this format.

xa ya za xb yb zb

Two vectors (xa,ya,za)(x_a, y_a, z_a) and (xb,yb,zb)(x_b, y_b, z_b) compare in dictionary order, that is, va<vbv_a < v_b if xa<xbx_a < x_b, or if xa=xbx_a = x_b and ya<yby_a < y_b, or if xa=xbx_a = x_b, ya=yby_a = y_b and za<zbz_a < z_b. 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)(v_i, v_j) is smaller than the pair (vk,vl)(v_k, v_l) if vi<vkv_i < v_k, or if vi=vkv_i = v_k and vj<vlv_j < v_l.