#include <bits/stdc++.h>

int main() {
	using namespace std;
	ios_base::sync_with_stdio(false), cin.tie(nullptr);

	int N; cin >> N;
	vector<array<int, 2>> input_cards(2*N);
	vector<array<int, 2>> cards(2*N);
	vector<int> other(4*N);
	vector<int> card_id(4*N);
	for (int i = 0; i < 2*N; i++) {
		auto& card = cards[i];
		for (int z = 0; z < 2; z++) {
			int a; cin >> a;
			input_cards[i][z] = a;
			card[z] = (z*N + (abs(a)-1)) * 2 + (a < 0);
		}
		card_id[card[0]] = card_id[card[1]] = i;
		other[card[0]] = card[1];
		other[card[1]] = card[0];
	}

	vector<bool> vis(2*N);
	vector<int> nxt(2*N, -1);

	int cur_path = -1;

	for (int st = 0; st < 2*N; st++) {
		if (vis[st]) continue;

		vector<int> edges;
		{
			int cur = 2*st+0;
			do {
				edges.push_back(cur);
				vis[cur>>1] = true;
				cur = other[cur^1];
			} while (cur != edges.front());
		}

		vector<pair<array<int, 2>, bool>> stk(edges.size());
		int lo = 0, hi = 0;
		for (int e : edges) {
			array<int, 2> cur{card_id[e], card_id[e]};
			if (hi >= 2 && stk[hi-2].second == stk[hi-1].second) {
				array<int, 2> a = stk[hi-2].first, b = stk[hi-1].first, c = cur;
				if (stk[hi-1].second) swap(a, c);
				hi -= 2;
				nxt[a[1]] = b[0];
				nxt[b[1]] = c[0];
				cur = {a[0], c[1]};
			}
			stk[hi++] = {cur, e&1};
		}
		while (hi >= 2 && stk[hi-2].second == stk[hi-1].second) {
			array<int, 2> a = stk[hi-2].first, b = stk[hi-1].first, c = stk[lo].first;
			if (stk[hi-1].second) swap(a, c);
			hi -= 2;
			nxt[a[1]] = b[0];
			nxt[b[1]] = c[0];
			stk[lo].first = {a[0], c[1]};
		}
		if (hi - lo != 2) {
			cout << "NO" << '\n';
			exit(0);
		}
		if (stk[lo].second) {
			swap(stk[lo], stk[lo+1]);
		}
		nxt[stk[lo+1].first[1]] = cur_path;
		nxt[stk[lo].first[1]] = stk[lo+1].first[0];
		cur_path = stk[lo].first[0];
	}

	cout << "YES" << '\n';
	for (int i = cur_path; i != -1; i = nxt[i]) {
		cout << input_cards[i][0] << ' ' << input_cards[i][1] << '\n';
	}

	return 0;
}

// You can contract down/down/down to down
// down/down/up to up
// up/down/down to up
// Until you eventually reach up/down

### Prompt

Please formulate a cpp solution to the following problem:

A balanced bracket sequence is defined as an integer sequence that can be built with the following rules:

  * The empty sequence is balanced. 
  * If [a_1,…,a_n] and [b_1,…, b_m] are balanced, then their concatenation [a_1,…,a_n,b_1,…,b_m] is balanced. 
  * If x is a positive integer and [a_1,…,a_n] is balanced, then [x,a_1,…,a_n,-x] is balanced. 



The positive numbers can be imagined as opening brackets and the negative numbers as closing brackets, where matching brackets must have the same type (absolute value). For example, [1, 2, -2, -1] and [1, 3, -3, 2, -2, -1] are balanced, but [1, 2, -1, -2] and [-1, 1] are not balanced.

There are 2n cards. Each card has a number on the front and a number on the back. Each integer 1,-1,2,-2,…,n,-n appears exactly once on the front of some card and exactly once on the back of some (not necessarily the same) card.

You can reorder the cards however you like. You are not allowed to flip cards, so numbers cannot move between the front and back. Your task is to order the cards so that the sequences given by the front numbers and the back numbers are both balanced, or report that it is impossible.

Input

The first line contains a single integer n (1≤ n≤ 2⋅ 10^5) — the number of bracket types, and half the number of cards.

The next 2n lines describe the cards. The i-th of these lines contains two integers a_i, b_i (-n≤ a_i,b_i≤ n, a_i≠ 0, b_i≠ 0) — the numbers on the front and back of the i-th card, respectively. Every integer 1,-1,2,-2,…,n,-n appears exactly once as a_i and exactly once as b_i.

Output

On the first line, output "YES" if it's possible to reorder these cards to satisfy the condition. Otherwise, output "NO". You can print each letter in any case (upper or lower).

If it is possible, on the next 2n lines output the cards in an order so that the front and back are both balanced. If there are multiple solutions, you may output any.

Examples

Input


5
1 3
-3 -5
4 -3
2 2
-1 -4
-2 5
3 -1
5 1
-4 4
-5 -2


Output


YES
1 3
4 -3
-4 4
-1 -4
5 1
3 -1
2 2
-2 5
-3 -5
-5 -2


Input


2
1 1
-1 2
2 -1
-2 -2


Output


NO

Note

In the first test case, the front numbers create the balanced sequence [1,4,-4,-1,5,3,2,-2,-3,-5] and the back numbers create the balanced sequence [3,-3,4,-4,1,-1,2,5,-5,-2].

In the second test case, the cards are given in an order so that the front numbers are balanced, but the back numbers create the unbalanced sequence [1,2,-1,-2]. If we swapped the second and third cards, we would balance the back numbers and unbalance the front numbers. But there is no order that balances both.

### Response

```cpp
#include <bits/stdc++.h>

int main() {
	using namespace std;
	ios_base::sync_with_stdio(false), cin.tie(nullptr);

	int N; cin >> N;
	vector<array<int, 2>> input_cards(2*N);
	vector<array<int, 2>> cards(2*N);
	vector<int> other(4*N);
	vector<int> card_id(4*N);
	for (int i = 0; i < 2*N; i++) {
		auto& card = cards[i];
		for (int z = 0; z < 2; z++) {
			int a; cin >> a;
			input_cards[i][z] = a;
			card[z] = (z*N + (abs(a)-1)) * 2 + (a < 0);
		}
		card_id[card[0]] = card_id[card[1]] = i;
		other[card[0]] = card[1];
		other[card[1]] = card[0];
	}

	vector<bool> vis(2*N);
	vector<int> nxt(2*N, -1);

	int cur_path = -1;

	for (int st = 0; st < 2*N; st++) {
		if (vis[st]) continue;

		vector<int> edges;
		{
			int cur = 2*st+0;
			do {
				edges.push_back(cur);
				vis[cur>>1] = true;
				cur = other[cur^1];
			} while (cur != edges.front());
		}

		vector<pair<array<int, 2>, bool>> stk(edges.size());
		int lo = 0, hi = 0;
		for (int e : edges) {
			array<int, 2> cur{card_id[e], card_id[e]};
			if (hi >= 2 && stk[hi-2].second == stk[hi-1].second) {
				array<int, 2> a = stk[hi-2].first, b = stk[hi-1].first, c = cur;
				if (stk[hi-1].second) swap(a, c);
				hi -= 2;
				nxt[a[1]] = b[0];
				nxt[b[1]] = c[0];
				cur = {a[0], c[1]};
			}
			stk[hi++] = {cur, e&1};
		}
		while (hi >= 2 && stk[hi-2].second == stk[hi-1].second) {
			array<int, 2> a = stk[hi-2].first, b = stk[hi-1].first, c = stk[lo].first;
			if (stk[hi-1].second) swap(a, c);
			hi -= 2;
			nxt[a[1]] = b[0];
			nxt[b[1]] = c[0];
			stk[lo].first = {a[0], c[1]};
		}
		if (hi - lo != 2) {
			cout << "NO" << '\n';
			exit(0);
		}
		if (stk[lo].second) {
			swap(stk[lo], stk[lo+1]);
		}
		nxt[stk[lo+1].first[1]] = cur_path;
		nxt[stk[lo].first[1]] = stk[lo+1].first[0];
		cur_path = stk[lo].first[0];
	}

	cout << "YES" << '\n';
	for (int i = cur_path; i != -1; i = nxt[i]) {
		cout << input_cards[i][0] << ' ' << input_cards[i][1] << '\n';
	}

	return 0;
}

// You can contract down/down/down to down
// down/down/up to up
// up/down/down to up
// Until you eventually reach up/down

```