#include <cstdio>
#include <cmath>
#include <algorithm>
#include <vector>
#include <chrono>
#include <queue>
#include <tuple>
#include <set>
using namespace std;

long long seed = std::chrono::high_resolution_clock::now().time_since_epoch().count();
unsigned int rx = seed, ry = seed >> 12, rz = seed >> 24;
inline unsigned int r()
{
	unsigned int t;
	rx ^= rx << 16; rx ^= rx >> 5; rx ^= rx << 1;
	t = rx; rx = ry; ry = rz; rz = t ^ rx ^ ry;
	return t;
}

int range(int a, int b)
{
	return a + r() % (b - a + 1);
}

double z()
{
	return (r() + 0.5) / ((double)4294967296);
}

int N, X[202], Y[202], R[202];

struct rect{
	int x1, y1, x2, y2;
}best[202], now[202], nxt[202];
int bestScore;

bool xIntersect(rect &a, rect &b)
{
	return max(a.x1, b.x1) < min(a.x2, b.x2);
}

bool yIntersect(rect &a, rect &b)
{
	return max(a.y1, b.y1) < min(a.y2, b.y2);
}

int score(rect *r)
{
	double pt = 0;
	for (int i = 0; i < N; i++){
		if (r[i].x1 == r[i].x2 || r[i].y1 == r[i].y2 || r[i].x1 < 0 || r[i].y1 < 0 || r[i].x2 > 10000 || r[i].y2 > 10000){
			return -1;
		}
		if (r[i].x1 <= X[i] && X[i] < r[i].x2 && r[i].y1 <= Y[i] && Y[i] < r[i].y2){
			int area = (r[i].x2 - r[i].x1) * (r[i].y2 - r[i].y1);
			double rat = 1 - 1. * min(R[i], area) / max(R[i], area);
			pt += (1 - rat * rat);
		}
		else return -1;
	}
	pt /= N;
	return (pt * 1e9 + 0.5);
}

void proc()
{
	auto start = std::chrono::system_clock::now();
	
	scanf ("%d", &N);
	for (int i = 0; i < N; i++){
		scanf ("%d %d %d", &X[i], &Y[i], &R[i]);
		tie(now[i].x1, now[i].y1) = tie(now[i].x2, now[i].y2) = tie(X[i], Y[i]);
		now[i].x2++; now[i].y2++;
	}

	const double TL = 4.85;
	while (1){
		double rat = std::chrono::duration<double>(std::chrono::system_clock::now() - start).count() / TL;
		if (rat >= 1) break;

		int step = 1e7 / N;
		double reduce = pow(1e-7, 1. / step);
		double temp = 1e5;
		int mv = N / 4;
		for (int i = 0; i < N; i++) {
			int x1 = X[i], x2 = X[i] + 1, y1 = Y[i], y2 = Y[i] + 1;
			x1 = range(now[i].x1, x1);
			x2 = range(x2, now[i].x2);
			y1 = range(now[i].y1, y1);
			y2 = range(y2, now[i].y2);
			now[i] = { x1, y1, x2, y2 };
		}

		int nowScore = score(now);
		for (int att = 0; att < step; att++, temp *= reduce){
			int i = range(1, N) - 1;

			for (int j = 0; j < N; j++) nxt[j] = now[j];
			int t = range(0, 3), m1 = range(1, range(1, mv)), m2 = range(1, m1);
			if (t == 0){
				nxt[i].x1 -= m1;
				if (range(0, 1)) nxt[i].x2 -= m2;
			}
			if (t == 1){
				nxt[i].x2 += m1;
				if (range(0, 1)) nxt[i].x1 += m2;
			}
			if (t == 2){
				nxt[i].y1 -= m1;
				if (range(0, 1)) nxt[i].y2 -= m2;
			}
			if (t == 3){
				nxt[i].y2 += m1;
				if (range(0, 1)) nxt[i].y1 += m2;
			}

			for (int j = 0; j < N; j++) if (j != i){
				if (xIntersect(nxt[i], nxt[j]) && yIntersect(nxt[i], nxt[j])){
					if (t == 0) nxt[j].x2 = nxt[i].x1;
					if (t == 1) nxt[j].x1 = nxt[i].x2;
					if (t == 2) nxt[j].y2 = nxt[i].y1;
					if (t == 3) nxt[j].y1 = nxt[i].y2;
				}
			}

			int nxtScore = score(nxt);
			if (nxtScore <= 0) continue;
			if (nowScore <= nxtScore || exp((nxtScore - nowScore) / temp) >= z()){
				nowScore = nxtScore;
				for (int j = 0; j < N; j++) now[j] = nxt[j];
			}
		}

		if (bestScore < nowScore){
			bestScore = nowScore;
			for (int j = 0; j < N; j++) best[j] = now[j];
		}
		for (int j = 0; j < N; j++) now[j] = best[j];
	}

	for (int i = 0; i < N; i++) printf ("%d %d %d %d\n", best[i].x1, best[i].y1, best[i].x2, best[i].y2);
}

int main()
{
	proc();
}
// #define _GLIBCXX_DEBUG // for STL debug (optional)
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <string>
#include <cstring>
#include <deque>
#include <list>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <complex>
#include <cmath>
#include <limits>
#include <cfloat>
#include <climits>
#include <ctime>
#include <cassert>
#include <numeric>
#include <fstream>
#include <functional>
#include <bitset>
using namespace std;
using ll = long long int;
using int64 = long long int;
 
template<typename T> void chmax(T &a, T b) {a = max(a, b);}
template<typename T> void chmin(T &a, T b) {a = min(a, b);}
template<typename T> void chadd(T &a, T b) {a = a + b;}
 
int dx[] = {0, 0, 1, -1};
int dy[] = {1, -1, 0, 0};
const int INF = 1LL << 29;
const ll LONGINF = 1LL << 60;
const ll MOD = 1000000007LL;
 
int main() {
    int K; cin >> K;
    ll N, M; cin >> N >> M;    
    vector<ll> A(K);
    for(auto &e : A) cin >> e;

    ll ub = 1LL << 60, lb = -1;
    while(ub - lb > 1) {
        ll mid = (ub + lb) / 2;
        // abs(BN - AM) <= mid
        // -mid <= BN - AM <= mid
        // [Lsum, Rsum]
        ll Lsum = 0, Rsum = 0;
        for(int i=0; i<K; i++) {
            ll L = max(0LL, (A[i] * M - mid + N - 1) / N);
            ll R = (mid + A[i] * M) / N;
            Lsum += L, Rsum += R;
        }
        if(Lsum <= M and M <= Rsum) ub = mid;
        else lb = mid;
    }

    {
        vector<ll> L(K), R(K);
        for(int i=0; i<K; i++) {
            ll l = max(0LL, (A[i] * M - ub + N - 1) / N);
            ll r = (ub + A[i] * M) / N;
            L[i] = l, R[i] = r;
        }
        vector<ll> ans = L;
        ll sum = accumulate(ans.begin(), ans.end(), 0LL);
        for(int i=0; i<K; i++) {
            ll rem = min(R[i] - ans[i], M - sum);
            ans[i] += rem;
            sum += rem;
        }
        for(int i=0; i<K; i++) {
            printf("%lld%c", ans[i], " \n"[i + 1 == K]);
        }
    }

    return 0;
}
