Problem: Vectors have their directions and two vectors make an angle between them. Given a set of three-dimensional vectors, your task is to find the pair among them that makes the smallest angle.



Input

The input is a sequence of datasets. A dataset specifies a set of three-dimensional vectors, some of which are directly given in the dataset and the others are generated by the procedure described below.

Each dataset is formatted as follows.


m n S W
x1 y1 z1
x2 y2 z2
:
xm ym zm


The first line contains four integers m, n, S, and W.

The integer m is the number of vectors whose three components are directly specified in the dataset. Starting from the second line, m lines have the three components of m vectors. The i-th line of which indicates the vector vi = (xi, yi, zi). All the vector components are positive integers less than or equal to 100.

The integer n is the number of vectors generated 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 i-th vector vi of the set has three components x[i], y[i], and z[i] generated by this procedure.

Here, values of S and W are the parameters S and W given in the first line of the dataset. You may assume 1 ≤ S ≤ 109 and 1 ≤ W ≤ 109.

The total number of vectors satisfies 2 ≤ m + n ≤ 12 × 104. Note that exactly 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 for all the datasets in the input never exceeds 16 × 105.

Output

For each dataset, output the pair of vectors among the specified set with the smallest non-zero angle in between. It is assured that there are at least two vectors having different directions.

Vectors should be indicated by their three components. The output for a pair of vectors va and vb should be formatted in a line as follows.


xa ya za xb yb zb


Two vectors (xa, ya, za) and (xb, yb, zb) are ordered in the 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 a vector pair is output, the smaller vector in this order should be output first.

If more than one pair makes the equal smallest angle, the pair that is the smallest among them in the dictionary order between vector pairs should be output. The pair (vi, vj) is smaller than the pair (vk, vl) if vi < vk, or if vi = vk and vj < vl.

Example

Input

4 0 2013 1124
1 1 1
2 2 2
2 1 1
1 2 1
2 100 131832453 129800231
42 40 46
42 40 46
0 100000 7004674 484521438
0 0 0 0


Output

1 1 1 1 2 1
42 40 46 83 79 91
92 92 79 99 99 85

Solution (in CPP):

Solution:
#include <bits/stdc++.h>
using namespace std;

using pii = pair<int,int>;
using ll = long long;
using ld = long double;
#define rep(i, j) for(int i=0; i < (int)(j); i++)
#define repeat(i, j, k) for(int i = (j); i < (int)(k); i++)
#define all(v) v.begin(),v.end()
#define debug(x) cerr << #x << " : " << x << endl

template<class T> bool set_min(T &a, const T &b) { return a > b  ? a = b, true : false; }
template<class T> bool set_max(T &a, const T &b) { return a < b  ? a = b, true : false; }
// vector
template<class T> istream&
operator >> (istream &is , vector<T> &v) { for(T &a : v) is >> a; return is; }
template<class T> ostream&
operator << (ostream &os , const vector<T> &v) { for(const T &t : v) os << "\t" << t; return os << endl; }
// pair
template<class T, class U> ostream&
operator << (ostream &os , const pair<T, U> &v) { return os << "<" << v.first << ", " << v.second << ">"; }

const int INF = 1 << 30;
const ll INFL = 1LL << 60;
const ld EPS = 1e-9;
bool eq(ld a, ld b) { return abs(a - b) < EPS; }
template<class T>
struct Point {
    T x, y, z;
    bool operator < (const Point<T> &r) const {
        return make_tuple(x, y, z) < make_tuple(r.x, r.y, r.z);
    }
};
template<class T>
ld length(const Point<T> &p) { return sqrtl(p.x * p.x + p.y * p.y + p.z * p.z); }
template<class T>
ld dot(const Point<T> &a, const Point<T> &b) { return a.x * b.x + a.y * b.y + a.z * b.z; }
template<class T>
ld angle(const Point<T> &a, const Point<T> &b) {
    return acosl(dot(a, b) / length(a) / length(b));
}
template<class T>
Point<ld> unit(Point<T> a) {
    Point<ld> p = {(ld)a.x, (ld)a.y, (ld)a.z};
    ld l = length(p);
    p.x /= l;
    p.y /= l;
    p.z /= l;
    return p;
}

bool solve() {
    int m, n, S, W; cin >> m >> n >> S >> W;
    if(m == 0 and n == 0 and S == 0 and W == 0) return false;
    vector<Point<int>> VI(m + n);
    rep(i, m) {
        cin >> VI[i].x >> VI[i].y >> VI[i].z;
    }
    int g = S;
    for(int i=m; i<m+n; i++) {
        VI[i].x = (g/7)    %100 + 1;
        VI[i].y = (g/700)  %100 + 1;
        VI[i].z = (g/70000)%100 + 1;
        if( g%2 == 0 ) { g = (g/2); }
        else           { g = (g/2) ^ W; }
    }
    sort(all(VI), [&] (Point<int> a, Point<int> b) {
            return unit(a).x > unit(b).x;
        });
    ld min_angle = 1e9;    
    Point<int> a, b;

    auto need_check = [&] (Point<int> &a, Point<int> &b) {
        ld alpha = acosl(unit(a).x);
        auto ss = cosl(alpha + min_angle);
        auto tt = unit(b).x;
        // cerr << ss << " " << tt << endl;
        return ss < tt + EPS*10;
    };
    
    queue<Point<int>> que;
    rep(i, VI.size()) {
        queue<Point<int>> nxt_que;
        while(que.size()) {
            auto p = que.front(); que.pop();
            if(not need_check(p, VI[i])) continue;
            ld ang = angle(VI[i], p);
            if(ang > EPS) {
                if(min_angle + EPS > ang) {                    
                    auto aa = VI[i], bb = p;
                    if(bb < aa) swap(aa, bb);
                    if(!eq(min_angle, ang) or make_pair(a, b) > make_pair(aa, bb)) {
                        a = aa;
                        b = bb;
                    }
                    min_angle = ang;
                }
            }
            nxt_que.push(p);
        }
        nxt_que.push(VI[i]);
        swap(que, nxt_que);
    }
    printf("%d %d %d %d %d %d\n",
           a.x, a.y, a.z,
           b.x, b.y, b.z);
    return true;
}

int main() {
    while(solve());
    return 0;
}