/*
Arthor: Ender_zzm
E-mail: zzm_ender_wiggin@outlook.com
Blog: oi.ender-zzm.pro
*/

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

inline int Isdigit(char c) {
	if (c < '0' || c > '9') return 0;
	return 1;
}
template <class T> 
T read(){
    register T x = 0, flag = 1;
    register char ch;
    while (!Isdigit(ch = getchar())) if (ch == '-') flag = -1;
    while (Isdigit(ch)) x = x * 10 + (ch & 15), ch = getchar();
	return x * flag;
}

template <class T>
inline void write(T x){
    if (x < 0)
        putchar('-'), x = -x;
    if(x >= 10) write(x / 10); 
    putchar(x % 10 + '0');
}

template<class T> inline bool Chkmax(T& x, const T& y) { return x < y ? x = y, true : false; }
template<class T> inline bool Chkmin(T& x, const T& y) { return x > y ? x = y, true : false; }

#define fi first
#define se second
#define debug(x) cout << #x << " = " << x << endl;
#define For(i, x, y) for (int i = (x); i <= (y); i++) 
#define Rep(i, x, y) for (int i = (x); i >= (y); i--) 
#define file(FILE_NAME) freopen(FILE_NAME".in", "r", stdin), freopen(FILE_NAME".out", "w", stdout)

const int maxn = 201;

int n;
int dp[maxn][maxn];
int a[maxn], b[maxn];
int vis[maxn], match[maxn];
int check(int l, int r) {
	for (int i = l, j = (l + r + 1) / 2; j <= r; j++, i++) {
		if (vis[i] == 2 || vis[j] == 1) return 0;
		//debug(match[i]); debug(match[j]);
		if (match[i] && match[j] && match[i] != match[j]) return 0;
	//	if (match[i] != match[j]) return 0;
	}
	return 1;
}
int main() {
	n = read<int>();
	For (i, 1, n) {
		a[i] = read<int>(), b[i] = read<int>();
		if ((~a[i] && vis[a[i]]) || (~b[i] && vis[b[i]]) || (~a[i] && ~b[i] && a[i] >= b[i])) {
			puts("No"); return 0;
		}
		if (~a[i]) vis[a[i]] = 1, match[a[i]] = i;
		if (~b[i]) vis[b[i]] = 2, match[b[i]] = i;
	}
	for (int len = 2; len <= 2 * n; len += 2) {
		for (int l = 1, r = l + len - 1; l <= 2 * n && r <= 2 * n; l += 2, r += 2) {
			for (int k = l + 1; k < r; k += 2) {
				dp[l][r] |= (dp[l][k] & dp[k + 1][r]);
				if (dp[l][r]) break;
			}
			if (dp[l][r]) continue;
			dp[l][r] = check(l, r);
		}
	}
	if (dp[1][2 * n]) printf("Yes");
	else puts("No");
	return 0;
}

#include <algorithm>
#include <bitset>
#include <cmath>
#include <functional>
#include <iomanip>
#include <iostream>
#include <limits>
#include <map>
#include <queue>
#include <random>
#include <set>
#include <tuple>
#include <vector>

using namespace std;

#define rep(i, n) for (int64_t i = 0; i < (int64_t)(n); i++)
#define irep(i, n) for (int64_t i = 0; i <= (int64_t)(n); i++)
#define rrep(i, n) for (int64_t i = (n)-1; i >= 0; i--)
#define rirep(i, n) for (int64_t i = n; i >= 0; i--)

#define chmax(a, b) (a) = max(a, b)
#define chmin(a, b) (a) = min(a, b)

/**
 * 近距離にあるペアが一組あるだけで他の全ての面積が小さくなってしまう
 * →企業毎に面積を変えられるようにする
 * */

struct Request {
  int id;
  int x, y;
  int r;
};

struct Answer {
  int x0, y0, x1, y1;
};

constexpr int FIELD_MAX = 10'000;

void solve(vector<Request>& req, vector<Answer>& ans) {
  for (const auto& r : req) {
    auto& a = ans[r.id];
    a.x0 = r.x;
    a.y0 = r.y;
    a.x1 = r.x + 1;
    a.y1 = r.y + 1;
  }

  int seed = 1;
  mt19937 rng(seed);

  array<int, 4> actions = {0, 1, 2, 3};
  queue<int> q;
  rep(i, ans.size()) { q.push(i); }

  while (!q.empty()) {
    int id = q.front();
    q.pop();

    auto& a = ans[id];

    shuffle(actions.begin(), actions.end(), rng);
    for (const int action : actions) {
      Answer new_region = {.x0 = a.x0 + (action == 0 ? -1 : 0),
                           .y0 = a.y0 + (action == 1 ? -1 : 0),
                           .x1 = a.x1 + (action == 2 ? 1 : 0),
                           .y1 = a.y1 + (action == 3 ? 1 : 0)};

      bool valid_region = (new_region.x0 >= 0 && new_region.x1 <= FIELD_MAX &&
                           new_region.y0 >= 0 && new_region.y1 <= FIELD_MAX);
      if (!valid_region) {
        continue;
      }

      bool ok = true;
      rep(i, ans.size()) {
        if (i != id) {
          const auto& other = ans[i];
          bool overlap =
              !(new_region.x1 <= other.x0 || new_region.x0 >= other.x1 ||
                new_region.y1 <= other.y0 || new_region.y0 >= other.y1);
          ok = (ok && !overlap);
        }
      }
      if (ok) {
        a = new_region;
        q.push(id);
        break;
      }
    }
  }
}

int main() {
  int N;
  cin >> N;

  vector<Request> req(N);
  rep(i, N) {
    auto& r = req[i];
    r.id = i;
    cin >> r.x >> r.y >> r.r;
  }

  vector<Answer> ans(N);

  solve(req, ans);

  rep(i, N) {
    const auto& a = ans[i];
    cout << a.x0 << " " << a.y0 << " " << a.x1 << " " << a.y1 << endl;
  }

  return 0;
}