#include <iostream>
#include <sstream>
#include <iomanip>
#include <vector>
#include <string>
#include <map>
#include <set>
#include <algorithm>
#include <numeric>
#include <iterator>
#include <functional>
#include <complex>
#include <queue>
#include <stack>
#include <cmath>
#include <cassert>
#include <tuple>
using namespace std;
typedef long long LL;
typedef complex<double> CMP;

class InsidePoints { public:
	vector <int> construct(vector <int> x, vector <int> y)
	{
		map<int, set<int>> x2y;
		for (int i = 0; i < x.size(); ++i)
			x2y[x[i]].insert(y[i]);

		vector<pair<int,int>> left;
		vector<pair<int, int>> upper;
		vector<pair<int, int>> lower;
		vector<pair<int, int>> right;

		int prevx = -99999999;
		int prevy = -99999999;
		for (auto it : x2y) {
			int x = it.first;
			set<int> ys = it.second;

			if (prevx == -99999999) {
				upper.emplace_back(x, *ys.rbegin() + 1);
				lower.emplace_back(x, *ys.begin() - 1);

				for (int yy = *ys.rbegin(); yy >= *ys.begin(); --yy)
					left.emplace_back(ys.count(yy) ? x - 1 : x, yy);
			}
			else {
				for (int xt = prevx + 1; xt < x; ++xt) {
					upper.emplace_back(xt, prevy+1);
					lower.emplace_back(xt, prevy);
				}
				upper.emplace_back(x, *ys.rbegin() + 1);
				int id = -1;
				for (int yy = *ys.rbegin(); yy >= *ys.begin(); --yy)
					if (ys.count(yy) == 0) {
						lower.emplace_back(x, yy);
						lower.emplace_back(x-1, id--);
					}
				lower.emplace_back(x, *ys.begin() - 1);
			}

			if (x2y.rbegin()->first == x) {
				for (int yy = *ys.rbegin(); yy >= *ys.begin(); --yy)
					right.emplace_back(ys.count(yy) ? x + 1 : x, yy);
			}

			prevx = x;
			prevy = *ys.rbegin();
		}

		vector<pair<int,int>> ans;
		ans.insert(ans.end(), left.begin(), left.end());
		ans.insert(ans.end(), lower.begin(), lower.end());
		ans.insert(ans.end(), right.rbegin(), right.rend());
		ans.insert(ans.end(), upper.rbegin(), upper.rend());
		vector<int> flat_ans;
		for (auto xy : ans) {
			flat_ans.push_back(xy.first);
			flat_ans.push_back(xy.second);
		}
		return flat_ans;
	}
};

// BEGIN CUT HERE
#include <ctime>
double start_time; string timer()
 { ostringstream os; os << " (" << int((clock()-start_time)/CLOCKS_PER_SEC*1000) << " msec)"; return os.str(); }
template<typename T> ostream& operator<<(ostream& os, const vector<T>& v)
 { os << "{ ";
   for(typename vector<T>::const_iterator it=v.begin(); it!=v.end(); ++it)
   os << '\"' << *it << '\"' << (it+1==v.end() ? "" : ", "); os << " }"; return os; }
void verify_case(const vector <int>& Expected, const vector <int>& Received) {
 bool ok = (Expected == Received);
 if(ok) cerr << "PASSED" << timer() << endl;  else { cerr << "FAILED" << timer() << endl;
 cerr << "\to: " << Expected << endl << "\tx: " << Received << endl; } }
#define CASE(N) {cerr << "Test Case #" << N << "..." << flush; start_time=clock();
#define END	 verify_case(_, InsidePoints().construct(x, y));}
int main(){

CASE(0)
	int x_[] = {4};
	  vector <int> x(x_, x_+sizeof(x_)/sizeof(*x_)); 
	int y_[] = {7};
	  vector <int> y(y_, y_+sizeof(y_)/sizeof(*y_)); 
	int __[] = {3, 7, 4, 8, 5, 6 };
	  vector <int> _(__, __+sizeof(__)/sizeof(*__)); 
END
CASE(1)
	int x_[] = {4, 6};
	  vector <int> x(x_, x_+sizeof(x_)/sizeof(*x_)); 
	int y_[] = {7, 7};
	  vector <int> y(y_, y_+sizeof(y_)/sizeof(*y_)); 
	int __[] = {3, 6, 7, 6, 7, 8, 5, 7, 3, 8 };
	  vector <int> _(__, __+sizeof(__)/sizeof(*__)); 
END
CASE(2)
	int x_[] = {1, 1, 2, 2};
	  vector <int> x(x_, x_+sizeof(x_)/sizeof(*x_)); 
	int y_[] = {1, 2, 1, 2};
	  vector <int> y(y_, y_+sizeof(y_)/sizeof(*y_)); 
	int __[] = {0, 0, 3, 0, 3, 3, 0, 3 };
	  vector <int> _(__, __+sizeof(__)/sizeof(*__)); 
END
CASE(3)
	int x_[] = {1, 2, 3, 3, 3, 3, 5, 4};
	  vector <int> x(x_, x_+sizeof(x_)/sizeof(*x_)); 
	int y_[] = {3, 3, 1, 5, 2, 4, 3, 3};
	  vector <int> y(y_, y_+sizeof(y_)/sizeof(*y_)); 
	int __[] = {0, 2, 2, 2, 2, 0, 4, 0, 4, 2, 6, 2, 6, 4, 4, 4, 4, 6, 2, 6, 2, 4, 3, 3, 1, 4, 0, 4 };
	  vector <int> _(__, __+sizeof(__)/sizeof(*__)); 
END
/*
CASE(4)
	int x_[] = ;
	  vector <int> x(x_, x_+sizeof(x_)/sizeof(*x_)); 
	int y_[] = ;
	  vector <int> y(y_, y_+sizeof(y_)/sizeof(*y_)); 
	int __[] = ;
	  vector <int> _(__, __+sizeof(__)/sizeof(*__)); 
END
CASE(5)
	int x_[] = ;
	  vector <int> x(x_, x_+sizeof(x_)/sizeof(*x_)); 
	int y_[] = ;
	  vector <int> y(y_, y_+sizeof(y_)/sizeof(*y_)); 
	int __[] = ;
	  vector <int> _(__, __+sizeof(__)/sizeof(*__)); 
END
*/
}
// END CUT HERE
