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

struct data{
    ll x,y,diff,ind,val;
};

struct data1{
    ll a,b;
};

struct cmp{
    bool operator()(data const &left,data const &right)
    {
        if(left.diff==right.diff)
            if(left.x+left.y==right.x+right.y) return left.ind<right.ind;
            else return left.x+left.y<right.x+right.y;
        else return left.diff<right.diff;
    }
};

struct cmp2{
    bool operator()(data1 const &left,data1 const &right)
    {
        if(left.a==right.a) return left.b<right.b;
        else return left.a<right.a;
    }
};

struct cmp3{
    bool operator()(data const &left,data const &right)
    {
        return left.ind<right.ind;
    }
};

struct cmp4{
    bool operator()(data const &left,data const &right)
    {
        return left.x+left.y<right.y+right.x;
    }
};

int main()
{
    ll n;
    cin>>n;
    data a[n];
    data1 c[n],ans[n];
    for(ll i=0;i<n;i++)
    {
        cin>>a[i].x>>a[i].y;
        a[i].diff=a[i].y-a[i].x;
        a[i].ind=i;
    }
    sort(a,a+n,cmp());
    for(ll i=0;i<n;i++)
    {
        cin>>c[i].a;
        c[i].b=i;
    }
    sort(c,c+n,cmp2());
    ll flag=0;
    for(ll i=0;i<n;i++)
    {
        if(a[i].diff==c[i].a)
        {
            //cout<<a[i].x<<a[i].y<<" "<<c[i].b<<endl;
            ans[c[i].b].a=a[i].x;
            ans[c[i].b].b=a[i].y;
            a[i].val=c[i].b;
        }
        else{
            flag=-1;
            break;
        }
    }
    if(flag==-1)
        cout<<"NO"<<endl;
    else{
        sort(a,a+n,cmp4());
        for(ll i=1;i<n;i++)
        {
            //cout<<a[i].x<<a[i].y<<" "<<a[i].val<<"  "<<a[i-1].x<<a[i-1].y<<" "<<a[i-1].val<<endl;
            if(a[i].x>=a[i-1].x && a[i].y>=a[i-1].y)
                if(a[i].val<a[i-1].val)
                {
                    flag=-1;
                    break;
                }
        }
        if(flag==-1)
            cout<<"NO"<<endl;
        else
        {
            cout<<"YES"<<endl;
            for(ll i=0;i<n;i++)
                cout<<ans[i].a<<" "<<ans[i].b<<endl;
        }
    }
}


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

struct data{
    ll x,y,diff,ind,val;
};

struct data1{
    ll a,b;
};

struct cmp{
    bool operator()(data const &left,data const &right)
    {
        if(left.diff==right.diff)
            return left.ind<right.ind;
        else return left.diff<right.diff;
    }
};

struct cmp2{
    bool operator()(data1 const &left,data1 const &right)
    {
        if(left.a==right.a) return left.b<right.b;
        else return left.a<right.a;
    }
};

struct cmp3{
    bool operator()(data const &left,data const &right)
    {
        return left.ind<right.ind;
    }
};

struct cmp4{
    bool operator()(data const &left,data const &right)
    {
        return left.x+left.y<right.y+right.x;
    }
};

int main()
{
    ll n;
    cin>>n;
    data a[n];
    data1 c[n],ans[n];
    for(ll i=0;i<n;i++)
    {
        cin>>a[i].x>>a[i].y;
        a[i].diff=a[i].y-a[i].x;
        a[i].ind=i;
    }
    sort(a,a+n,cmp());
    for(ll i=0;i<n;i++)
    {
        cin>>c[i].a;
        c[i].b=i;
    }
    sort(c,c+n,cmp2());
    ll flag=0;
    for(ll i=0;i<n;i++)
    {
        if(a[i].diff==c[i].a)
        {
            //cout<<a[i].x<<a[i].y<<" "<<c[i].b<<endl;
            ans[c[i].b].a=a[i].x;
            ans[c[i].b].b=a[i].y;
            a[i].val=c[i].b;
        }
        else{
            flag=-1;
            break;
        }
    }
    if(flag==-1)
        cout<<"NO"<<endl;
    else{
        sort(a,a+n,cmp4());
        for(ll i=1;i<n;i++)
        {
            //cout<<a[i].x<<a[i].y<<" "<<a[i].val<<"  "<<a[i-1].x<<a[i-1].y<<" "<<a[i-1].val<<endl;
            if(a[i].x>=a[i-1].x && a[i].y>=a[i-1].y)
                if(a[i].val<a[i-1].val)
                {
                    flag=-1;
                    break;
                }
        }
        if(flag==-1)
            cout<<"NO"<<endl;
        else
        {
            cout<<"YES"<<endl;
            for(ll i=0;i<n;i++)
                cout<<ans[i].a<<" "<<ans[i].b<<endl;
        }
    }
}


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

struct data{
    ll x,y,diff,ind,val;
};

struct data1{
    ll a,b;
};

struct cmp{
    bool operator()(data const &left,data const &right)
    {
        return left.diff<right.diff;
    }
};

struct cmp2{
    bool operator()(data1 const &left,data1 const &right)
    {
        return left.a<right.a;
    }
};

struct cmp3{
    bool operator()(data const &left,data const &right)
    {
        return left.ind<right.ind;
    }
};

struct cmp4{
    bool operator()(data const &left,data const &right)
    {
        return left.x+left.y<right.y+right.x;
    }
};

int main()
{
    ll n;
    cin>>n;
    data a[n];
    data1 c[n],ans[n];
    for(ll i=0;i<n;i++)
    {
        cin>>a[i].x>>a[i].y;
        a[i].diff=a[i].y-a[i].x;
        a[i].ind=i;
    }
    sort(a,a+n,cmp());
    for(ll i=0;i<n;i++)
    {
        cin>>c[i].a;
        c[i].b=i;
    }
    sort(c,c+n,cmp2());
    ll flag=0;
    for(ll i=0;i<n;i++)
    {
        if(a[i].diff==c[i].a)
        {
            ans[c[i].b].a=a[i].x;
            ans[c[i].b].b=a[i].y;
            a[i].val=c[i].b;
        }
        else{
            flag=-1;
            break;
        }
    }
    if(flag==-1)
        cout<<"NO"<<endl;
    else{
        sort(a,a+n,cmp4());
        for(ll i=1;i<n;i++)
        {
            //cout<<a[i].x<<a[i].y<<" "<<a[i-1].x<<a[i-1].y<<endl;
            if(a[i].x>=a[i-1].x && a[i].y>=a[i-1].y)
                if(a[i].val<a[i-1].val)
                {
                    flag=-1;
                    break;
                }
        }
        if(flag==-1)
            cout<<"NO"<<endl;
        else
        {
            cout<<"YES"<<endl;
            for(ll i=0;i<n;i++)
                cout<<ans[i].a<<" "<<ans[i].b<<endl;
        }
    }
}


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

struct data{
    ll x,y,diff,ind,val;
};

struct data1{
    ll a,b;
};

struct cmp{
    bool operator()(data const &left,data const &right)
    {
        return left.diff<right.diff;
    }
};

struct cmp2{
    bool operator()(data1 const &left,data1 const &right)
    {
        if(left.a==right.a) return left.b<right.b;
        else return left.a<right.a;
    }
};

struct cmp3{
    bool operator()(data const &left,data const &right)
    {
        return left.ind<right.ind;
    }
};

struct cmp4{
    bool operator()(data const &left,data const &right)
    {
        return left.x+left.y<right.y+right.x;
    }
};

int main()
{
    ll n;
    cin>>n;
    data a[n];
    data1 c[n],ans[n];
    for(ll i=0;i<n;i++)
    {
        cin>>a[i].x>>a[i].y;
        a[i].diff=a[i].y-a[i].x;
        a[i].ind=i;
    }
    sort(a,a+n,cmp());
    for(ll i=0;i<n;i++)
    {
        cin>>c[i].a;
        c[i].b=i;
    }
    sort(c,c+n,cmp2());
    ll flag=0;
    for(ll i=0;i<n;i++)
    {
        if(a[i].diff==c[i].a)
        {
            ans[c[i].b].a=a[i].x;
            ans[c[i].b].b=a[i].y;
            a[i].val=c[i].b;
        }
        else{
            flag=-1;
            break;
        }
    }
    if(flag==-1)
        cout<<"NO"<<endl;
    else{
        sort(a,a+n,cmp4());
        for(ll i=1;i<n;i++)
        {
            //cout<<a[i].x<<a[i].y<<" "<<a[i].val<<"  "<<a[i-1].x<<a[i-1].y<<" "<<a[i-1].val<<endl;
            if(a[i].x>=a[i-1].x && a[i].y>=a[i-1].y)
                if(a[i].val<a[i-1].val)
                {
                    flag=-1;
                    break;
                }
        }
        if(flag==-1)
            cout<<"NO"<<endl;
        else
        {
            cout<<"YES"<<endl;
            for(ll i=0;i<n;i++)
                cout<<ans[i].a<<" "<<ans[i].b<<endl;
        }
    }
}


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

struct data{
    ll x,y,diff,ind;
};

struct data1{
    ll a,b;
};

struct cmp{
    bool operator()(data const &left,data const &right)
    {
        return left.diff<right.diff;
    }
};

struct cmp2{
    bool operator()(data1 const &left,data1 const &right)
    {
        return left.a<right.a;
    }
};

struct cmp3{
    bool operator()(data const &left,data const &right)
    {
        return left.ind<right.ind;
    }
};

int main()
{
    ll n;
    cin>>n;
    data a[n];
    data1 c[n],ans[n];
    for(ll i=0;i<n;i++)
    {
        cin>>a[i].x>>a[i].y;
        a[i].diff=a[i].y-a[i].x;
        a[i].ind=i;
    }
    sort(a,a+n,cmp());
    for(ll i=0;i<n;i++)
    {
        cin>>c[i].a;
        c[i].b=i;
    }
    sort(c,c+n,cmp2());
    ll flag=0;
    for(ll i=0;i<n;i++)
    {
        if(a[i].diff==c[i].a)
        {
            ans[c[i].b].a=a[i].x;
            ans[c[i].b].b=a[i].y;
        }
        else{
            flag=-1;
            break;
        }
    }
    if(flag==-1)
        cout<<"NO"<<endl;
    else{
        cout<<"YES"<<endl;
        for(ll i=0;i<n;i++)
            cout<<ans[i].a<<" "<<ans[i].b<<endl;
    }
}


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

struct data{
    ll x,y,diff,ind,val;
};

struct data1{
    ll a,b;
};

struct cmp{
    bool operator()(data const &left,data const &right)
    {
        return left.diff<right.diff;
    }
};

struct cmp2{
    bool operator()(data1 const &left,data1 const &right)
    {
        if(left.a==right.a) return left.b<right.b;
        else return left.a<right.a;
    }
};

struct cmp3{
    bool operator()(data const &left,data const &right)
    {
        return left.ind<right.ind;
    }
};

struct cmp4{
    bool operator()(data const &left,data const &right)
    {
        return left.x+left.y<right.y+right.x;
    }
};

int main()
{
    ll n;
    cin>>n;
    data a[n];
    data1 c[n],ans[n];
    for(ll i=0;i<n;i++)
    {
        cin>>a[i].x>>a[i].y;
        a[i].diff=a[i].y-a[i].x;
        a[i].ind=i;
    }
    sort(a,a+n,cmp());
    for(ll i=0;i<n;i++)
    {
        cin>>c[i].a;
        c[i].b=i;
    }
    sort(c,c+n,cmp2());
    ll flag=0;
    for(ll i=0;i<n;i++)
    {
        if(a[i].diff==c[i].a)
        {
            ans[c[i].b].a=a[i].x;
            ans[c[i].b].b=a[i].y;
            a[i].val=c[i].b;
        }
        else{
            flag=-1;
            break;
        }
    }
    if(flag==-1)
        cout<<"NO"<<endl;
    else{
        sort(a,a+n,cmp4());
        for(ll i=1;i<n;i++)
        {
            cout<<a[i].x<<a[i].y<<" "<<a[i].val<<"  "<<a[i-1].x<<a[i-1].y<<" "<<a[i-1].val<<endl;
            if(a[i].x>=a[i-1].x && a[i].y>=a[i-1].y)
                if(a[i].val<a[i-1].val)
                {
                    flag=-1;
                    break;
                }
        }
        if(flag==-1)
            cout<<"NO"<<endl;
        else
        {
            cout<<"YES"<<endl;
            for(ll i=0;i<n;i++)
                cout<<ans[i].a<<" "<<ans[i].b<<endl;
        }
    }
}


/* -*- coding: utf-8 -*-
 *
 * 0596C.cc: C. Wilbur and Points
 */

#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<iostream>
#include<string>
#include<vector>
#include<map>
#include<set>
#include<stack>
#include<list>
#include<queue>
#include<deque>
#include<algorithm>
#include<numeric>
#include<utility>
#include<complex>
#include<functional>

using namespace std;

/* constant */

const int MAX_N = 100000;
const int MIN_W = -100000;
const int MAX_W = 100000;
const int MAX_Y = 100000;
const int L = MAX_W - MIN_W + 1;

/* typedef */

typedef pair<int,int> pii;
typedef vector<pii> vpii;

/* global variables */

vpii wps[L];
int wpns[L], cxs[MAX_Y + 1];
pii aps[MAX_N];

/* subroutines */

/* main */

int main() {
  //freopen("input.txt", "r", stdin);
  //freopen("output.txt", "w", stdout);

  int n;
  scanf("%d", &n);

  int minw = -MIN_W, maxw = -MIN_W;
  for (int i = 0; i < n; i++) {
    int x, y;
    scanf("%d%d", &x, &y);
    int w = y - x - MIN_W;
    wps[w].push_back(pii(x, y));
    if (minw > w) minw = w;
    if (maxw < w) maxw = w;
  }
  for (int w = minw; w <= maxw; w++) sort(wps[w].begin(), wps[w].end());

  memset(cxs, -1, sizeof(cxs));
  cxs[0] = 0;

  for (int i = 0; i < n; i++) {
    int wi;
    scanf("%d", &wi);
    wi -= MIN_W;
    vpii &wpi = wps[wi];
    int &wpni = wpns[wi];

    if (wpni < wpi.size()) {
      int wx = wpi[wpni].first, wy = wpi[wpni].second;
      if (cxs[wy] == wx) {
	aps[i] = wpi[wpni];
	cxs[wy]++;
	if (wy < MAX_Y && cxs[wy + 1] < 0) cxs[wy + 1] = 0;
	wpni++;
      }
      else { puts("NO"); return 0; }
    }
    else { puts("NO"); return 0; }
  }

  puts("YES");
  for (int i = 0; i < n; i++)
    printf("%d %d\n", aps[i].first, aps[i].second);
  return 0;
}


#include <bits/stdc++.h>

using namespace std;

#define fi first
#define se second
#define pf push_front
#define pb push_back
#define mk make_pair
#define all(c) (c).begin(), (c).end()
#define sz(x) (int)x.size()
#define SWS ios_base::sync_with_stdio(false)
#define rfile freopen("input.txt", "r", stdin)
#define wfile freopen("output.txt", "w", stdout)
#define files rfile; wfile

typedef long long ll;
typedef long double ld;

const int Z = (int)1e5 + 111;
const int inf = (int)1e9 + 111;
const ll llinf = (ll)1e18 + 5;
const int MOD = (int)1e9 + 7;

pair <int, int> ans[Z];
int x[Z];
int y[Z];

int main () {
	srand(time(0));
	//files;
	SWS;
	int n;
	cin >> n;
	set <pair<int, pair<int, int> > > mn;
	for (int i = 1; i <= n; ++i) {
        cin >> x[i] >> y[i];
        mn.insert(mk(y[i] - x[i], mk(x[i], y[i])));
	}
	for (int i = 1; i <= n; ++i) {
        int w;
        cin >> w;
        auto it = mn.lower_bound(mk(w, mk(0, 0)));
        if (it == mn.end() || (it->fi != w)) {
            cout << "NO";
            return 0;
        }
        ans[i] = it -> se;
        mn.erase(it);
	}
	multiset <pair<int, int> > mn2;
	for (int i = 1; i <= n; ++i) {
        mn2.insert(mk(x[i], y[i]));
	}
	for (int i = 1; i < n; ++i) {
        mn2.erase(ans[i]);
        pair <int, int> mi = *mn2.begin();
        if (mi.fi <= ans[i].fi && mi.se <= ans[i].se) {
            cout << "NO";
            return 0;
        }
	}
	cout << "YES\n";
	for (int i = 1; i <= n; ++i) {
        cout << ans[i].fi << ' ' << ans[i].se << '\n';
	}
	return 0;
}


#include <bits/stdc++.h>

using namespace std;

#define fi first
#define se second
#define pf push_front
#define pb push_back
#define mk make_pair
#define all(c) (c).begin(), (c).end()
#define sz(x) (int)x.size()
#define SWS ios_base::sync_with_stdio(false)
#define rfile freopen("input.txt", "r", stdin)
#define wfile freopen("output.txt", "w", stdout)
#define files rfile; wfile

typedef long long ll;
typedef long double ld;

const int Z = (int)1e5 + 111;
const int inf = (int)1e9 + 111;
const ll llinf = (ll)1e18 + 5;
const int MOD = (int)1e9 + 7;

pair <int, int> ans[Z];
int x[Z];
int y[Z];

int main () {
	srand(time(0));
	//files;
	SWS;
	int n;
	cin >> n;
	set <pair<int, pair<int, int> > > mn;
	for (int i = 1; i <= n; ++i) {
        cin >> x[i] >> y[i];
        mn.insert(mk(y[i] - x[i], mk(x[i], y[i])));
	}
	for (int i = 1; i <= n; ++i) {
        int w;
        cin >> w;
        auto it = mn.lower_bound(mk(w, mk(0, 0)));
        if (it == mn.end()) {
            cout << "NO";
            return 0;
        }
        ans[i] = it -> se;
        mn.erase(it);
	}
	multiset <pair<int, int> > mn2;
	for (int i = 1; i <= n; ++i) {
        mn2.insert(mk(x[i], y[i]));
	}
	for (int i = 1; i < n; ++i) {
        mn2.erase(ans[i]);
        pair <int, int> mi = *mn2.begin();
        if (mi.fi <= ans[i].fi && mi.se <= ans[i].se) {
            cout << "NO";
            return 0;
        }
	}
	cout << "YES\n";
	for (int i = 1; i <= n; ++i) {
        cout << ans[i].fi << ' ' << ans[i].se << '\n';
	}
	return 0;
}


#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define MS(a) memset(a,0,sizeof(a))
#define MP make_pair
#define PB push_back
const int INF = 0x3f3f3f3f;
const ll INFLL = 0x3f3f3f3f3f3f3f3fLL;
inline ll read(){
    ll x=0,f=1;char ch=getchar();
    while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}
    while(ch>='0'&&ch<='9'){x=x*10+ch-'0';ch=getchar();}
    return x*f;
}
//////////////////////////////////////////////////////////////////////////
const int maxn = 1e5+10;

int n,v[maxn],k[maxn];
map<pair<int,int>,pair<int,int> > mp;
map<int,int> cnt;

struct node{
	int x,y,t;
}a[maxn],b[maxn];

bool cmp1(node A,node B){
	if(A.x>B.x && A.y>B.y) return true;
	return false;
}

bool cmp2(node A, node B){
	if(A.x == B.x && A.y == B.y) {
		if(A.x == B.x) return A.y<B.y;
		return A.x < B.x;
	}
	return A.t < B.t;
}

int main(){
	cin >> n;
	for(int i=0; i<n; i++){
		scanf("%d%d",&a[i].x,&a[i].y);
		a[i].t = a[i].y-a[i].x; b[i].t = a[i].t;
		b[i].x = a[i].x; b[i].y = a[i].y;
	}

	for(int i=0; i<n; i++)
		v[i]=read(),k[i]=v[i];
	sort(b,b+n,cmp1);
	for(int i=0; i<n; i++){
		if(a[i].x!=b[i].x || a[i].y!=b[i].y){
			puts("NO");
			return 0;
		}
	}
	sort(a,a+n,cmp2);
	sort(k,k+n);
	for(int i=0; i<n; i++){
		if(k[i] != a[i].t) {
			puts("NO");
			return 0;
		}
		mp[MP(k[i],cnt[k[i]]++)] = MP(a[i].x,a[i].y);
	}

	puts("YES");
	cnt.clear();
	for(int i=0; i<n; i++){
		int x = mp[MP(v[i],cnt[v[i]])].first;
		int y = mp[MP(v[i],cnt[v[i]]++)].second;
		cout << x << " " << y << endl;
	}

	return 0;
}


#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define MS(a) memset(a,0,sizeof(a))
#define MP make_pair
#define PB push_back
const int INF = 0x3f3f3f3f;
const ll INFLL = 0x3f3f3f3f3f3f3f3fLL;
inline ll read(){
    ll x=0,f=1;char ch=getchar();
    while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}
    while(ch>='0'&&ch<='9'){x=x*10+ch-'0';ch=getchar();}
    return x*f;
}
//////////////////////////////////////////////////////////////////////////
const int maxn = 1e5+10;

int n,v[maxn],k[maxn];
map<pair<int,int>,pair<int,int> > mp;
map<int,int> cnt;

struct node{
	int x,y,t;
}a[maxn],b[maxn];

bool cmp(node A, node B){
	if(A.x == B.x && A.y == B.y) {
		if(A.x == B.x) return A.y<B.y;
		return A.x < B.x;
	}
	return A.t < B.t;
}

int main(){
	cin >> n;
	for(int i=0; i<n; i++){
		scanf("%d%d",&a[i].x,&a[i].y);
		a[i].t = a[i].y-a[i].x; b[i].t = a[i].t;
		b[i].x = a[i].x; b[i].y = a[i].y;
	}
	sort(b,b+n,cmp);
	for(int i=0; i<n; i++)
		v[i]=read(),k[i]=v[i];
	sort(k,k+n);
	for(int i=0; i<n; i++){
		if(k[i] != b[i].t) {
			puts("NO");
			return 0;
		}
		mp[MP(k[i],cnt[k[i]]++)] = MP(b[i].x,b[i].y);
	}

	puts("YES");
	cnt.clear();
	for(int i=0; i<n; i++){
		int x = mp[MP(v[i],cnt[v[i]])].first;
		int y = mp[MP(v[i],cnt[v[i]]++)].second;
		cout << x << " " << y << endl;
	}

	return 0;
}


#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define MS(a) memset(a,0,sizeof(a))
#define MP make_pair
#define PB push_back
const int INF = 0x3f3f3f3f;
const ll INFLL = 0x3f3f3f3f3f3f3f3fLL;
inline ll read(){
    ll x=0,f=1;char ch=getchar();
    while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}
    while(ch>='0'&&ch<='9'){x=x*10+ch-'0';ch=getchar();}
    return x*f;
}
//////////////////////////////////////////////////////////////////////////
const int maxn = 1e5+10;

int n;
map<int,set<pair<int,int> > > mp;
int w[maxn],ww[maxn],k[maxn];
vector<pair<int,int> > v;

int main(){
	cin >> n;
	for(int i=0; i<n; i++){
		int x,y; scanf("%d%d",&x,&y);
		k[i] = y-x;
		mp[y-x].insert(MP(x,y));
	}
	for(int i=0; i<n; i++){
		scanf("%d",&w[i]); ww[i] = w[i];
	}
	sort(k,k+n);
	sort(w,w+n);
	for(int i=0; i<n; i++){
		if(w[i] != k[i]){
			puts("NO");
			return 0;
		}
	}
	for(int i=0; i<n; i++){
		set<pair<int,int> >::iterator it = mp[ww[i]].begin();
		v.push_back(*it);
		mp[ww[i]].erase(it);
	}
	for(int i=1; i<n; i++){
		if(v[i].first<=v[i-1].first && v[i].second<=v[i-1].second){
			puts("NO");
			return 0;
		}
	}
	puts("YES");
	for(int i=0; i<n; i++){
		cout << v[i].first << " " << v[i].second << endl;
	}

	return 0;
}


#include<iostream>
using namespace std;
#include<string>
#define REP(i,a,b) \
for(int i=a; i<b; i++)
#include<bits/stdc++.h>
#include<algorithm>
#define ll long long int
typedef vector<int> vi;
typedef pair<int,int> ii;
#define sz(a) int((a).size())
#define pb push_back
#define all(c) (c).begin(),(c).end()
#define present(c,x) ((c).find(x) != (c).end())
#define tr(c,i) for(typeof(c.begin()) i = (c).begin(); i != (c).end();i++)
int main()
{
	int n;
	cin >> n;
	vector< pair<int,int> > arr;
	REP(i,0,n)
	{
		int a,b;
		cin >> a >> b;
		arr.push_back(make_pair(a,b));
	}
	sort(arr.begin(),arr.end());
	reverse(arr.begin(),arr.end());
	vector<int> v[200001];
	vector< pair<int,int> > ans;
	REP(i,0,n)
	{
		int sxy = arr[i].second - arr[i].first + 100000;
		if(sxy > 200000)
		{
			cout << "NO";
			return 0;
		}
		v[sxy].push_back(i);
	}
	int xmax = INT_MIN, ymax = INT_MIN;
	REP(i,0,n)
	{
		int w;
		cin >> w;
		w = w+100000;
		if(v[w].empty())
		{
			cout << "NO";
			return 0;
		}
		int index = v[w].back();
		if(arr[index].first < xmax &&  arr[index].second <= ymax)
		{
			cout << "NO";
			return 0;
		}
		else if(arr[index].first <= xmax && arr[index].second < ymax)
		{
			cout << "NO";
			return 0;
		}
		else
		{
			xmax = arr[index].first;
			ymax = arr[index].second;
		}
		ans.push_back(arr[index]);
		v[w].pop_back();
	}
	cout << "YES\n";
	REP(i,0,n)
	{
		cout << ans[i].first << " " << ans[i].second << "\n";
	}
}


#include<iostream>
using namespace std;
#include<string>
#define REP(i,a,b) \
for(int i=a; i<b; i++)
#include<bits/stdc++.h>
#include<algorithm>
#define ll long long int
typedef vector<int> vi;
typedef pair<int,int> ii;
#define sz(a) int((a).size())
#define pb push_back
#define all(c) (c).begin(),(c).end()
#define present(c,x) ((c).find(x) != (c).end())
#define tr(c,i) for(typeof(c.begin()) i = (c).begin(); i != (c).end();i++)
int main()
{
	int n;
	cin >> n;
	vector< pair<int,int> > arr;
	REP(i,0,n)
	{
		int a,b;
		cin >> a >> b;
		arr.push_back(make_pair(a,b));
	}
	sort(arr.begin(),arr.end());
	reverse(arr.begin(),arr.end());
	vector<int> v[200001];
	vector< pair<int,int> > ans;
	REP(i,0,n)
	{
		int sxy = arr[i].second - arr[i].first + 100000;
		if(sxy > 200000)
		{
			cout << "NO";
			return 0;
		}
		v[sxy].push_back(i);
	}
	REP(i,0,n)
	{
		int w;
		cin >> w;
		w = w+100000;
		if(v[w].empty())
		{
			cout << "NO";
			return 0;
		}
		int index = v[w].back();
		ans.push_back(arr[index]);
		v[w].pop_back();
	}
	cout << "YES\n";
	REP(i,0,n)
	{
		cout << ans[i].first << " " << ans[i].second << "\n";
	}
}


///By Stephan Ramirez dsramirezc@unal.edu.co
#include<bits/stdc++.h>
#define ms(a,v) memset(a,v,sizeof a)
#define ll long long
#define N 100005
using namespace std;
int n;
deque<int> arr[N];
pair<int,int> aux[N];
int s[N];
int main(){
	#ifdef LOCAL
		freopen("in.txt","r",stdin);
		//freopen("out.txt","w",stdout);
	#endif
	scanf("%d",&n);
	for(int i=0;i<n;i++){
        int a,b;
        scanf("%d %d",&a,&b);
        aux[i]=make_pair(a,b);
	}
	sort(aux+0,aux+n);
	for(int i=0;i<n;i++)
        arr[aux[i].first].push_back(aux[i].second);
    for(int i=0;i<n;i++)
        scanf("%d",&s[i]);
    int l=0;
    int r=0;
    int ans[n][2];
    bool f=true;
    for(int i=0;i<n;i++){
        bool flag=false;
        for(int j=l;j<=r;j++){
            if(arr[j].size()>0 && (arr[j][0]-j)==s[i]){
                ans[i][0]=j;
                ans[i][1]=arr[j][0];
                arr[j].pop_front();
                flag=true;

                if(j==r){
                    r++;
                }

                break;
            }
        }
        if(!flag){
            f=false;
            break;
        }
    }
    if(f){
        puts("YES");
        for(int i=0;i<n;i++)
            printf("%d %d\n",ans[i][0],ans[i][1]);
    }else{
        puts("NO");
    }
	return 0;
}


///By Stephan Ramirez dsramirezc@unal.edu.co
#include<bits/stdc++.h>
#define ms(a,v) memset(a,v,sizeof a)
#define ll long long
#define N 100005
using namespace std;
int n;
deque<int> arr[N];
pair<int,int> aux[N];
int s[N];
map<int,bool> mp[N];
map<int,bool> mp1[N];
vector<pair<int,int> >pos[N];
vector<pair<int,int> >neg[N];

int main(){
	#ifdef LOCAL
		freopen("in.txt","r",stdin);
		//freopen("out.txt","w",stdout);
	#endif
	scanf("%d",&n);
	for(int i=0;i<n;i++){
        int a,b;
        scanf("%d %d",&a,&b);
        aux[i]=make_pair(a,b);
        mp1[a][b]=true;
	}
	sort(aux+0,aux+n);
	for(int i=0;i<n;i++)
        arr[aux[i].first].push_back(aux[i].second);
    for(int i=0;i<n;i++)
        scanf("%d",&s[i]);
    int l=0;
    int r=0;
    int ans[n][2];
    bool f=true;
    pos[0].push_back(make_pair(0,0));

    for(int i=0;i<n;i++){
        bool flag=false;
        if(s[i]>=0){
            if(pos[s[i]].size()>0){
                ans[i][0]=pos[s[i]].back().first;
                ans[i][1]=pos[s[i]].back().second;
                pos[s[i]].pop_back();
                flag=true;
                mp[ans[i][0]][ans[i][1]]=true;
                if(mp1[ans[i][0]][ans[i][1]+1] && (ans[i][0]==0 || mp[ans[i][0]-1][ans[i][1]+1])){
                    int w1=ans[i][1]+1-ans[i][0];
                    if(w1>=0){
                        pos[w1].push_back(make_pair(ans[i][0],ans[i][1]+1));
                    }else{
                        neg[-w1].push_back(make_pair(ans[i][0],ans[i][1]+1));
                    }

                }
                if(mp1[ans[i][0]+1][ans[i][1]] && (ans[i][1]==0 || mp[ans[i][0]+1][ans[i][1]-1])){
                    int w1=ans[i][1]-ans[i][0]-1;
                    if(w1>=0){
                        pos[w1].push_back(make_pair(ans[i][0]+1,ans[i][1]));
                    }else{
                        neg[-w1].push_back(make_pair(ans[i][0]+1,ans[i][1]));
                    }

                }
            }
        }else{
            if(neg[-s[i]].size()>0){
                ans[i][0]=neg[-s[i]].back().first;
                ans[i][1]=neg[-s[i]].back().second;
                neg[-s[i]].pop_back();
                flag=true;
                mp[ans[i][0]][ans[i][1]]=true;
                if(mp1[ans[i][0]][ans[i][1]+1] && (ans[i][0]==0 || mp[ans[i][0]-1][ans[i][1]+1])){
                    int w1=ans[i][1]+1-ans[i][0];
                    if(w1>=0){
                        pos[w1].push_back(make_pair(ans[i][0],ans[i][1]+1));
                    }else{
                        neg[-w1].push_back(make_pair(ans[i][0],ans[i][1]+1));
                    }

                }
                if(mp1[ans[i][0]+1][ans[i][1]] && (ans[i][1]==0 || mp[ans[i][0]+1][ans[i][1]-1])){
                    int w1=ans[i][1]-ans[i][0]-1;
                    if(w1>=0){
                        pos[w1].push_back(make_pair(ans[i][0]+1,ans[i][1]));
                    }else{
                        neg[-w1].push_back(make_pair(ans[i][0]+1,ans[i][1]));
                    }

                }
            }
        }
        if(!flag){
            f=false;
            break;
        }
    }
    if(f){
        puts("YES");
        for(int i=0;i<n;i++)
            printf("%d %d\n",ans[i][0],ans[i][1]);
    }else{
        puts("NO");
    }
	return 0;
}


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

int n;
int x[maxn], y[maxn];
int arr[maxn];
map<int, set<pair<int, int>>>M;

int main(){
    scanf("%d", &n);
    for(int i=0; i<n; i++)
        scanf("%d%d", &x[i], &y[i]), M[y[i]-x[i]].insert(make_pair(x[i],y[i]));
    stringstream ss;
    ss<<"YES"<<endl;
    for(int i=0; i<n; i++) scanf("%d", &arr[i]);
    for(int i=0; i<n; i++){
        pair<int, int> tmp;
        if(!M[arr[i]].size()) return puts("NO"), 0;
        tmp = *M[arr[i]].begin();
        M[arr[i]].erase(M[arr[i]].begin());
        int x = tmp.first, y = tmp.second;
        if(M[arr[i]-1].count(make_pair(x, y-1)) || M[arr[i]+1].count(make_pair(x-1,y))) return puts("NO"), 0;
        ss<<x<<" "<<y<<endl;
    }
    cout<<ss.str();
    return 0;
}


#include <bits/stdc++.h>
#define LL long long
#define maxn 120000
using namespace std;

int n;
bool used[maxn];

struct A{
    int x, y, id;
}p[maxn];

bool cmp1(A a, A b){ //x
    if(a.x == b.x) return a.y < b.y;
    else return a.x < b.x;
}

bool cmp2(A a, A b){ //y
    if(a.y == b.y) return a.x < b.x;
    return a.y < b.y;
}

int B[maxn];
queue<A>q1, q2;
vector<pair<int, int>>ans;

int main(){
    scanf("%d", &n);
    for(int i=0; i<n; i++)
        scanf("%d%d", &p[i].x, &p[i].y), p[i].id = i;
    sort(p, p+n, cmp1);
    for(int i=0; i<n; i++)
        q1.push(p[i]);
    sort(p, p+n, cmp2);
    for(int i=0; i<n; i++)
        q2.push(p[i]);
    for(int i=0; i<n; i++)
        scanf("%d", &B[i]);
    for(int i=0; i<n; i++){
        while(!q1.empty() && used[q1.front().id]) q1.pop();
        while(!q2.empty() && used[q2.front().id]) q2.pop();
        A a, b;
        if(!q1.empty())
            a = q1.front();
        if(!q2.empty())
            b = q2.front();
        if(a.y - a.x == B[i] && !q1.empty()){
            ans.push_back(make_pair(a.x, a.y));
            used[a.id] = 1;
        }else if(b.y - b.x == B[i] && !q2.empty()){
            ans.push_back(make_pair(b.x, b.y));
            used[b.id] = 1;
        }else{
            puts("NO");
            return 0;
        }
    }
    puts("YES");
    for(int i=0; i<ans.size(); i++)
        cout<<ans[i].first<<" "<<ans[i].second<<endl;
    return 0;
}


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

int n;
int x[maxn], y[maxn];
int arr[maxn];
map<int, set<pair<int, int>>>M;

int main(){
    scanf("%d", &n);
    for(int i=0; i<n; i++)
        scanf("%d%d", &x[i], &y[i]), M[y[i]-x[i]].insert(make_pair(x[i],y[i]));
    stringstream ss;
    ss<<"YES"<<endl;
    for(int i=0; i<n; i++) scanf("%d", &arr[i]);
    for(int i=0; i<n; i++){
        pair<int, int> tmp;
        tmp = *M[arr[i]].begin();
        M[arr[i]].erase(M[arr[i]].begin());
        int x = tmp.first, y = tmp.second;
        if(M[arr[i]-1].count(make_pair(x, y-1)) || M[arr[i]+1].count(make_pair(x-1,y))) return puts("NO"), 0;
        ss<<x<<" "<<y<<endl;
    }
    cout<<ss.str();
    return 0;
}


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

int n,w;
int x[maxn], y[maxn];
map<int, set<pair<int, int>>>M;

int main(){
    scanf("%d", &n);
    for(int i=0; i<n; i++)
        scanf("%d%d", &x[i], &y[i]), M[y[i]-x[i]].insert(make_pair(x[i],y[i]));
    stringstream ss;
    ss<<"YES"<<endl;
    for(int i=0; i<n; i++){
        scanf("%d", &w);
        pair<int, int> tmp;
        if(!M[w].size()) return puts("NO"), 0;
        tmp = *M[w].begin();
        M[w].erase(M[w].begin());
        int x = tmp.first, y = tmp.second;
        if(M[w-1].count(make_pair(x, y-1)) || M[w+1].count(make_pair(x-1,y))) return puts("NO"), 0;
        ss<<x<<" "<<y<<endl;
    }
    cout<<ss.str();
    return 0;
}


//#include<bits/stdc++.h>
//#pragma comment(linker, "/STACK:1024000000,1024000000")
#include<stdio.h>
#include<algorithm>
#include<queue>
#include<string.h>
#include<iostream>
#include<math.h>
#include<stack>
#include<set>
#include<map>
#include<vector>
#include<iomanip>
#include<bitset>
using namespace std;         //

#define ll long long
#define ull unsigned long long
#define pb push_back
#define FOR(a) for(int i=1;i<=a;i++)
#define sqr(a) (a)*(a)
#define dis(a,b) sqrt(sqr(a.x-b.x)+sqr(a.y-b.y))
ll qp(ll a,ll b,ll mod){
	ll t=1;while(b){if(b&1)t=t*a%mod;b>>=1;a=a*a%mod;}return t;
}
struct DOT{int x;int y;};
inline void read(int &x){int k=0;char f=1;char c=getchar();for(;!isdigit(c);c=getchar())if(c=='-')f=-1;for(;isdigit(c);c=getchar())k=k*10+c-'0';x=k*f;}
void ex(){puts("NO");exit(0);}
const int dx[4]={0,0,-1,1};
const int dy[4]={1,-1,0,0};
const int inf=0x3f3f3f3f;
const ll Linf=0x3f3f3f3f3f3f3f3f;
const ll mod=1e9+7;;

const int maxn=2e5+34;

DOT a[maxn];

int n;
bool cmp(DOT a,DOT b){
	if(a.y==b.y)return a.x<b.x;
	return a.y<b.y;
}
queue<int>spc[maxn];

DOT b[maxn];
int rowmax[maxn],colmax[maxn];

int main(){
	scanf("%d",&n);
	for(int i=1;i<=n;i++){
		scanf("%d%d",&a[i].x,&a[i].y);
	}
	sort(a+1,a+1+n,cmp);
	for(int i=1;i<=n;i++){
		int x;scanf("%d",&x);
		x+=100000;

		spc[x].push(i);
	}
	for(int i=1;i<=n;i++){

		int now=a[i].y-a[i].x+100000;

		//cout<<spc[now].size()<<endl;

		if(spc[now].empty()){ex();}
		else{
			int x=spc[now].front();spc[now].pop();
			b[x]=a[i];
			if(x < colmax[a[i].x] || x < rowmax[a[i].y]){
				ex();
			}
			colmax[a[i].x]=x;
			rowmax[a[i].y]=x;
		}
	}
	puts("YES");
	for(int i=1;i<=n;i++){
		printf("%d %d\n",b[i].x,b[i].y);
	}
}


//#include<bits/stdc++.h>
//#pragma comment(linker, "/STACK:1024000000,1024000000")
#include<stdio.h>
#include<algorithm>
#include<queue>
#include<string.h>
#include<iostream>
#include<math.h>
#include<stack>
#include<set>
#include<map>
#include<vector>
#include<iomanip>
#include<bitset>
using namespace std;         //

#define ll long long
#define ull unsigned long long
#define pb push_back
#define FOR(a) for(int i=1;i<=a;i++)
#define sqr(a) (a)*(a)
#define dis(a,b) sqrt(sqr(a.x-b.x)+sqr(a.y-b.y))
ll qp(ll a,ll b,ll mod){
	ll t=1;while(b){if(b&1)t=t*a%mod;b>>=1;a=a*a%mod;}return t;
}
struct DOT{int x;int y;};
inline void read(int &x){int k=0;char f=1;char c=getchar();for(;!isdigit(c);c=getchar())if(c=='-')f=-1;for(;isdigit(c);c=getchar())k=k*10+c-'0';x=k*f;}
void ex(){puts("NO");exit(0);}
const int dx[4]={0,0,-1,1};
const int dy[4]={1,-1,0,0};
const int inf=0x3f3f3f3f;
const ll Linf=0x3f3f3f3f3f3f3f3f;
const ll mod=1e9+7;;

const int maxn=2e5+34;

DOT a[maxn];

int n;
bool cmp(DOT a,DOT b){
	if(a.y==b.y)return a.x<b.x;
	return a.y<b.y;
}
queue<int>spc[maxn];

DOT b[maxn];
int rowmax[maxn],colmax[maxn];

int main(){
	scanf("%d",&n);
	for(int i=1;i<=n;i++){
		scanf("%d%d",&a[i].x,&a[i].y);
	}
	sort(a+1,a+1+n,cmp);
	for(int i=1;i<=n;i++){
		int x;scanf("%d",&x);
		x+=100000;

		spc[x].push(i);
	}
	for(int i=1;i<=n;i++){

		int now=a[i].y-a[i].x+100000;

		//cout<<spc[now].size()<<endl;

		if(spc[now].empty()){ex();}
		else{
			int x=spc[now].front();spc[now].pop();
			b[x]=a[i];
			if(x < colmax[a[i].x] || x < rowmax[a[i].y]){
				ex();
			}
			rowmax[a[i].x]=x;
			colmax[a[i].y]=x;
		}
	}
	puts("YES");
	for(int i=1;i<=n;i++){
		printf("%d %d\n",b[i].x,b[i].y);
	}
}


#include <bits/stdc++.h>
#pragma GCC optimize("Ofast,no-stack-protector,unroll-loops")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#define ll          long long
#define pb          push_back
#define mp 			make_pair
#define pii         pair<ll,ll>
#define vi          vector<ll>
#define vii         vector<pii>
#define mi          map<ll,ll>
#define mii         map<pii,ll>
#define all(a)      (a).begin(),(a).end()
#define fi          first
#define si          second
#define sz(x)       (ll)x.size()
#define endl        '\n'
#define checkbit(n, b) ((n >> b) & 1)
#define mod        1000000007
#define puts(n)		cout<<n;
#define rep(i,l,u) for(i=l;i<u;i++)
#define mset(m,v) memset(m,v,sizeof(m))
using namespace std;

map<ll,vi>m;
ll x[100001],y[100001];
ll c[200002];

bool compare(ll a,ll b)
{
    if(x[a]<=y[a] and x[b]<=y[b])
    return 1;
    return 0;
}

void solve()
{
    ll n,i;
    cin>>n;
    ll w[n];
    for(i=0;i<n;i++)
    {
        cin>>x[i]>>y[i];
        m[y[i]-x[i]].pb(i);
    }
    for(i=0;i<n;i++)
    {
        cin>>w[i];
    }
    vi v;
    for(auto it=m.begin();it!=m.end();it++)
    {
        sort(it->second.begin(),it->second.end());
    }
    for(i=0;i<n;i++)
    {
        if(m[w[i]].size()>c[w[i]+100000])
        {
            v.pb(m[w[i]][c[w[i]+100000]]);
            c[w[i]+100000]++;
        }
        else
        {
            break;
        }
    }
    if(i!=n)
    {
        cout<<"NO";
        return;
    }
    cout<<"YES\n";
    for(i=0;i<n;i++)
    {
        cout<<x[v[i]]<<" "<<y[v[i]]<<endl;
    }

}

signed main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	int t=1;
	//cin>>t;
	while(t--)
	{
		solve();
	}
	return 0;
}


#include <bits/stdc++.h>
#pragma GCC optimize("Ofast,no-stack-protector,unroll-loops")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#define ll          long long
#define pb          push_back
#define mp 			make_pair
#define pii         pair<ll,ll>
#define vi          vector<ll>
#define vii         vector<pii>
#define mi          map<ll,ll>
#define mii         map<pii,ll>
#define all(a)      (a).begin(),(a).end()
#define fi          first
#define si          second
#define sz(x)       (ll)x.size()
#define endl        '\n'
#define checkbit(n, b) ((n >> b) & 1)
#define mod        1000000007
#define puts(n)		cout<<n;
#define rep(i,l,u) for(i=l;i<u;i++)
#define mset(m,v) memset(m,v,sizeof(m))
using namespace std;

map<ll,vi>m;
ll x[100001],y[100001];
ll c[200002];

bool compare(ll a,ll b)
{
    if(x[a]<=x[b] and y[a]<=y[b])
    return 1;
    return 0;
}

void solve()
{
    ll n,i;
    cin>>n;
    ll w[n];
    for(i=0;i<n;i++)
    {
        cin>>x[i]>>y[i];
        m[y[i]-x[i]].pb(i);
    }
    for(i=0;i<n;i++)
    {
        cin>>w[i];
    }
    vi v;
    for(auto it=m.begin();it!=m.end();it++)
    {
        sort(it->second.begin(),it->second.end(),compare);
    }
    vi v2;
    for(i=0;i<n;i++)
    {
        if(m[w[i]].size()>c[w[i]+100000])
        {
            v.pb(m[w[i]][c[w[i]+100000]]);
            c[w[i]+100000]++;
            v2.pb(v[i]);
            //cout<<v2[i]<<" ";
        }
        else
        {
            break;
        }
    }
    if(i!=n)
    {
        cout<<"NO";
        return;
    }
    sort(v2.begin(),v2.end(),compare);
    for(i=0;i<n;i++)
    {
        if(v[i]!=v2[i])
        break;
    }
    if(i!=n)
    {
        cout<<"NO";
        return ;
    }
    cout<<"YES\n";
    for(i=0;i<n;i++)
    {
        cout<<x[v[i]]<<" "<<y[v[i]]<<endl;
    }

}

signed main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	int t=1;
	//cin>>t;
	while(t--)
	{
		solve();
	}
	return 0;
}


#include <bits/stdc++.h>
#pragma GCC optimize("Ofast,no-stack-protector,unroll-loops")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#define ll          long long
#define pb          push_back
#define mp 			make_pair
#define pii         pair<ll,ll>
#define vi          vector<ll>
#define vii         vector<pii>
#define mi          map<ll,ll>
#define mii         map<pii,ll>
#define all(a)      (a).begin(),(a).end()
#define fi          first
#define si          second
#define sz(x)       (ll)x.size()
#define endl        '\n'
#define checkbit(n, b) ((n >> b) & 1)
#define mod        1000000007
#define puts(n)		cout<<n;
#define rep(i,l,u) for(i=l;i<u;i++)
#define mset(m,v) memset(m,v,sizeof(m))
using namespace std;

map<ll,vi>m;
ll x[100001],y[100001];
ll c[200002];

bool compare(ll a,ll b)
{
    if(x[a]<=x[b] and y[a]<=y[b])
    return 1;
    return 0;
}

void solve()
{
    ll n,i;
    cin>>n;
    ll w[n];
    for(i=0;i<n;i++)
    {
        cin>>x[i]>>y[i];
        m[y[i]-x[i]].pb(i);
    }
    for(i=0;i<n;i++)
    {
        cin>>w[i];
    }
    vi v;
    for(auto it=m.begin();it!=m.end();it++)
    {
        sort(it->second.begin(),it->second.end(),compare);
    }
    for(i=0;i<n;i++)
    {
        if(m[w[i]].size()>c[w[i]+100000])
        {
            v.pb(m[w[i]][c[w[i]+100000]]);
            c[w[i]+100000]++;
        }
        else
        {
            break;
        }
    }
    if(i!=n)
    {
        cout<<"NO";
        return;
    }
    cout<<"YES\n";
    for(i=0;i<n;i++)
    {
        cout<<x[v[i]]<<" "<<y[v[i]]<<endl;
    }

}

signed main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	int t=1;
	//cin>>t;
	while(t--)
	{
		solve();
	}
	return 0;
}


#include <bits/stdc++.h>
#pragma GCC optimize("Ofast,no-stack-protector,unroll-loops")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#define ll          long long
#define pb          push_back
#define mp 			make_pair
#define pii         pair<ll,ll>
#define vi          vector<ll>
#define vii         vector<pii>
#define mi          map<ll,ll>
#define mii         map<pii,ll>
#define all(a)      (a).begin(),(a).end()
#define fi          first
#define si          second
#define sz(x)       (ll)x.size()
#define endl        '\n'
#define checkbit(n, b) ((n >> b) & 1)
#define mod        1000000007
#define puts(n)		cout<<n;
#define rep(i,l,u) for(i=l;i<u;i++)
#define mset(m,v) memset(m,v,sizeof(m))
using namespace std;

map<ll,vi>m;
ll x[100001],y[100001];
ll c[200002];

bool compare(pii a,pii b)
{
    if(x[a.fi]<x[b.fi] and y[a.fi]<y[b.fi])
    return 1;
    if(x[a.fi]==x[b.fi] and y[a.fi]<y[b.fi])
    return 1;
    if(x[a.fi]<x[b.fi] and y[a.fi]==y[b.fi])
    return 1;
    if(x[a.fi]>x[b.fi] and y[a.fi]>y[b.fi])
    return 0;
    if(x[a.fi]==x[b.fi] and y[a.fi]>y[b.fi])
    return 0;
    if(x[a.fi]>x[b.fi] and y[a.fi]==y[b.fi])
    return 0;
    return a.si<b.si;
}

bool compare1(ll a,ll b)
{
    return x[a]<x[b];
}

void solve()
{
    ll n,i;
    cin>>n;
    ll w[n];
    for(i=0;i<n;i++)
    {
        cin>>x[i]>>y[i];
        m[y[i]-x[i]].pb(i);
    }
    for(i=0;i<n;i++)
    {
        cin>>w[i];
    }
    vi v;
    for(auto it=m.begin();it!=m.end();it++)
    {
        sort(it->second.begin(),it->second.end(),compare1);
    }
    vii v2;
    for(i=0;i<n;i++)
    {
        if(m[w[i]].size()>c[w[i]+100000])
        {
            v.pb(m[w[i]][c[w[i]+100000]]);
            c[w[i]+100000]++;
            v2.pb(mp(v[i],i));
        }
        else
        {
            break;
        }
    }
    if(i!=n)
    {
        cout<<"NO";
        return;
    }
    sort(v2.begin(),v2.end(),compare);
    for(i=0;i<n;i++)
    {
        //cout<<v[i]<<" ";
        if(v[i]!=v2[i].fi)
        break;
    }
    if(i!=n)
    {
        cout<<"NO";
        return ;
    }
    cout<<"YES\n";
    for(i=0;i<n;i++)
    {
        cout<<x[v[i]]<<" "<<y[v[i]]<<endl;
    }

}

signed main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	int t=1;
	//cin>>t;
	while(t--)
	{
		solve();
	}
	return 0;
}


#include <bits/stdc++.h>
#pragma GCC optimize("Ofast,no-stack-protector,unroll-loops")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#define ll          long long
#define pb          push_back
#define mp 			make_pair
#define pii         pair<ll,ll>
#define vi          vector<ll>
#define vii         vector<pii>
#define mi          map<ll,ll>
#define mii         map<pii,ll>
#define all(a)      (a).begin(),(a).end()
#define fi          first
#define si          second
#define sz(x)       (ll)x.size()
#define endl        '\n'
#define checkbit(n, b) ((n >> b) & 1)
#define mod        1000000007
#define puts(n)		cout<<n;
#define rep(i,l,u) for(i=l;i<u;i++)
#define mset(m,v) memset(m,v,sizeof(m))
using namespace std;

map<ll,vi>m;
ll x[100001],y[100001];
ll c[200002];

bool compare(pii a,pii b)
{
    if(x[a.fi]<x[b.fi] and y[a.fi]<y[b.fi])
    return 1;
    if(x[a.fi]==x[b.fi] and y[a.fi]<y[b.fi])
    return 1;
    if(x[a.fi]<x[b.fi] and y[a.fi]==y[b.fi])
    return 1;
    if(x[a.fi]>x[b.fi] and y[a.fi]>y[b.fi])
    return 0;
    if(x[a.fi]==x[b.fi] and y[a.fi]>y[b.fi])
    return 0;
    if(x[a.fi]>x[b.fi] and y[a.fi]==y[b.fi])
    return 0;
    return a.si<b.si;
}

void solve()
{
    ll n,i;
    cin>>n;
    ll w[n];
    for(i=0;i<n;i++)
    {
        cin>>x[i]>>y[i];
        m[y[i]-x[i]].pb(i);
    }
    for(i=0;i<n;i++)
    {
        cin>>w[i];
    }
    vi v;
    for(auto it=m.begin();it!=m.end();it++)
    {
        sort(it->second.begin(),it->second.end());
    }
    vii v2;
    for(i=0;i<n;i++)
    {
        if(m[w[i]].size()>c[w[i]+100000])
        {
            v.pb(m[w[i]][c[w[i]+100000]]);
            c[w[i]+100000]++;
            v2.pb(mp(v[i],i));
        }
        else
        {
            break;
        }
    }
    if(i!=n)
    {
        cout<<"NO";
        return;
    }
    sort(v2.begin(),v2.end(),compare);
    for(i=0;i<n;i++)
    {
        if(v[i]!=v2[i].fi)
        break;
    }
    if(i!=n)
    {
        cout<<"NO";
        return ;
    }
    cout<<"YES\n";
    for(i=0;i<n;i++)
    {
        cout<<x[v[i]]<<" "<<y[v[i]]<<endl;
    }

}

signed main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	int t=1;
	//cin>>t;
	while(t--)
	{
		solve();
	}
	return 0;
}


#include <bits/stdc++.h>

using namespace std;

int main()
{
    int n, w;
    cin >> n;
    int X[n], Y[n], K[n];
    vector <pair<int,int>> V, A;
    for (int i = 0; i < n; i++)
    {
        cin >> X[i] >> Y[i];
        V.push_back({Y[i]-X[i],i});
    }
    for (int i = 0; i < n; i++)
    {
        cin >> w;
        A.push_back({w,i});
    }
    sort(V.begin(),V.end());
    sort(A.begin(),A.end());
    for (int i = 0; i < n; i++)
    {
        if (V[i].first != A[i].first)
        {
            cout << "NO";
            return 0;
        }
        else
        {
            K[A[i].second] = V[i].second;
        }
    }
    cout << "YES" << "\n";
    for (int i = 0; i < n; i++)
    {
        cout << X[K[i]] << " " << Y[K[i]] << "\n";
    }
    return 0;
}


#include<bits/stdc++.h>
typedef long long int ull;
typedef long long int ll;
#define ub upper_bound
#define lb lower_bound
#define pb push_back
#define m_p make_pair
#define int_char_index(a) a-'0'
#define neginf -1000000001
#define inf 1000000000000000001
#define mod 1000000007
#define F first
#define S second
#define fr(j,x,y) for(j=x;j<=y;j++)
#define N 1000001
#define frn(i,x,y) for(i=x;i>=y;i--)
using namespace std;
ll power(ll x, ll y){ ll res = 1; x = x % mod;  while (y > 0){ if (y & 1)res = (res*x) % mod; y = y>>1;x = (x*x) % mod;  }return res;}
ll bst(ll a[],ll item,ll index,ll n){ ll b=index,e=n,mid; mid=(b+e)/2; while(a[mid]!=item&&b<=e) { if(a[mid]<item) b=mid+1; else e=mid-1; mid=(b+e)/2; } return mid; }
ll max3(ll x,ll y,ll z){    return max(max(x,y),z);}
ll min3(ll x,ll y,ll z){    return min(min(x,y),z);}
string cir_shift(string s){     string s1;  ll len; len=s.size(); s1=s.substr(1,len-1); s1.pb(s[0]); return s1;}
void swap1(ll &a,ll &b){ll temp;temp=a;a=b;b=temp;}
map<ll,vector<pair<ll,ll> > > mp;
map<ll,pair<ll,ll>> mval;

bool comp(pair<ll,ll> a,pair<ll,ll> b)
{
    if(a.F==b.F)
        return a.S<b.S;

    return a.F<b.F;
}
int main()
{
    ios::sync_with_stdio(false);
	cin.tie();cout.tie();

    ll n,i,x,y,val,len;
    cin>>n;
    map<ll,vector<ll> > mw;
    map<ll,vector<pair<ll,ll> > >::iterator it;
    map<pair<ll,ll>,ll>::iterator it1;
    vector<pair<ll,ll> > v1;
    vector<ll> v2;
    ll w[n+1];
    fr(i,1,n)
    {
        cin>>x>>y;
        mp[y-x].pb(m_p(x,y));
    }

    fr(i,1,n)
    {
        cin>>w[i];
        mw[w[i]].pb(i);
    }
    for(it=mp.begin();it!=mp.end();it++)
    {
        v1 = it->S;
        if(v1.size()!=mw[it->F].size())
        {
            cout<<"NO";
            return 0;
        }
        val = it->F;
        sort(mp[val].begin(),mp[val].end(),comp);
        sort(mw[val].begin(),mw[val].end());
    }

    for(it=mp.begin();it!=mp.end();it++)
    {
        val = it->F;
        len = mw[val].size();

        fr(i,0,len-1)
        {
            mval[mw[val][i]] = mp[val][i];
        }
    }

    cout<<"YES\n";

    fr(i,1,n)
    {
        cout<<mval[i].F<<" "<<mval[i].S<<endl;
    }

}


#include<bits/stdc++.h>
typedef long long int ull;
typedef long long int ll;
#define ub upper_bound
#define lb lower_bound
#define pb push_back
#define m_p make_pair
#define int_char_index(a) a-'0'
#define neginf -1000000001
#define inf 1000000000000000001
#define mod 1000000007
#define F first
#define S second
#define fr(j,x,y) for(j=x;j<=y;j++)
#define N 1000001
#define frn(i,x,y) for(i=x;i>=y;i--)
using namespace std;
ll power(ll x, ll y){ ll res = 1; x = x % mod;  while (y > 0){ if (y & 1)res = (res*x) % mod; y = y>>1;x = (x*x) % mod;  }return res;}
ll bst(ll a[],ll item,ll index,ll n){ ll b=index,e=n,mid; mid=(b+e)/2; while(a[mid]!=item&&b<=e) { if(a[mid]<item) b=mid+1; else e=mid-1; mid=(b+e)/2; } return mid; }
ll max3(ll x,ll y,ll z){    return max(max(x,y),z);}
ll min3(ll x,ll y,ll z){    return min(min(x,y),z);}
string cir_shift(string s){     string s1;  ll len; len=s.size(); s1=s.substr(1,len-1); s1.pb(s[0]); return s1;}
void swap1(ll &a,ll &b){ll temp;temp=a;a=b;b=temp;}
map<ll,vector<pair<ll,ll> > > mp;
map<ll,pair<ll,ll>> mval;
map<pair<ll,ll>,ll> mrank;

bool comp(pair<ll,ll> a,pair<ll,ll> b)
{
    if(a.F==b.F)
        return a.S<b.S;

    return a.F<b.F;
}
int main()
{
    ios::sync_with_stdio(false);
	cin.tie();cout.tie();

    ll n,i,x,y,val,len,mx=0,my=0,cx=0,cy=0;
    cin>>n;
    map<ll,vector<ll> > mw;
    map<ll,vector<pair<ll,ll> > >::iterator it;
    map<pair<ll,ll>,ll>::iterator it1;
    vector<pair<ll,ll> > v1;
    vector<ll> v2;
    ll w[n+1];
    fr(i,1,n)
    {
        cin>>x>>y;
        mp[y-x].pb(m_p(x,y));
        mx = max(mx,x);
        my = max(my,y);
        if(x==y)
        {
            if(x>cx)
            {
                cx=cy=x;
            }
        }
    }

    fr(i,1,n)
    {
        cin>>w[i];
        mw[w[i]].pb(i);
    }
    for(it=mp.begin();it!=mp.end();it++)
    {
        v1 = it->S;
        if(v1.size()!=mw[it->F].size())
        {
            cout<<"NO";
            return 0;
        }
        val = it->F;
        sort(mp[val].begin(),mp[val].end(),comp);
        sort(mw[val].begin(),mw[val].end());
    }

    for(it=mp.begin();it!=mp.end();it++)
    {
        val = it->F;
        len = mw[val].size();

        fr(i,0,len-1)
        {
            mval[mw[val][i]] = mp[val][i];
            mrank[mp[val][i]] = mw[val][i];
        }
    }

    x=mx;

    while(x>0)
    {
        if(mrank[m_p(x,0)]<mrank[m_p(x-1,0)])
        {
            cout<<"NO\n";
            return 0;
        }
        x--;
    }

    y = my;

    while(y>0)
    {
        if(mrank[m_p(0,y)]<mrank[m_p(0,y-1)])
        {
            cout<<"NO\n";
            return 0;
        }
        y--;
    }

    while(cx>0||cy>0)
    {
        // in x

        x=cx;y=cy;

        while(x>0)
        {
            if(mrank[m_p(x,cy)]<mrank[m_p(x-1,cy)])
            {
                cout<<"NO\n";
                return 0;
            }
            x--;
        }

        // in y

        x=cx;y=cy;

        while(y>0)
        {
            if(mrank[m_p(cx,y)]<mrank[m_p(cx,y-1)])
            {
                cout<<"NO\n";
                return 0;
            }
            y--;
        }
        cx--;cy--;
    }

    cout<<"YES\n";
    fr(i,1,n)
    {
        cout<<mval[i].F<<" "<<mval[i].S<<endl;
    }

}


#include<bits/stdc++.h>
#define god dimasi5eks
#pragma GCC optimize("O3")
#define fi first
#define se second
#define pb push_back
#define pf push_front

// #define fisier 1

using namespace std;

typedef long long ll;

const int mod = 1000000007;
const double dancila = 3.14159265359; // PI
const double eps = 1e-9;

int n, xx[100002], cnt[100002], rcnt[100002];
pair<int, int> pct[100002];

bool cmp(int a, int b)
{
	if(pct[a].se - pct[a].fi == pct[b].se - pct[b].fi)
		return pct[a].fi < pct[b].fi;
	return pct[a].se - pct[a].fi < pct[b].se - pct[b].fi;
}

bool cmp2(int a, int b)
{
	if(cnt[a] == cnt[b])
		return a < b;
	return cnt[a] < cnt[b];
}
pair<int, int> sol[100002];
bool ok = 1;

int aib[200002];
void upd(int nod, int val)
{
	for(; nod <= 200000; nod += (nod & (-nod)))
		aib[nod] = max(aib[nod], val);
}
int compute(int nod)
{
	int ans = 0;
	for(; nod; nod -= (nod & (-nod)))
		ans = max(ans, aib[nod]);
	return ans;
}
int main()
{

    #ifdef fisier
        ifstream cin("input.in");
        ofstream cout("output.out");
    #endif

    ios_base::sync_with_stdio(false);
    cin.tie(NULL);

	cin >> n;
	for(int i = 1; i <= n; ++i)
		cin >> pct[i].fi >> pct[i].se, xx[i] = i, pct[i].fi++, pct[i].se++;
	sort(xx + 1, xx + n + 1, cmp);
	for(int i = 1; i <= n; ++i)
		cin >> cnt[i], rcnt[i] = i;

	sort(rcnt + 1, rcnt + n + 1, cmp2);
	int a = 1, b = 1;
	while(a <= n && b <= n)
	{
		vector<int> points;
		vector<int> queries;
		if(cnt[rcnt[b]] != pct[xx[a]].se - pct[xx[a]].fi)
		{
			cout << "NO";
			return 0;
		}
		int val = cnt[rcnt[b]];
		while(a <= n && pct[xx[a]].se - pct[xx[a]].fi == val)
			points.pb(xx[a]), ++a;
		while(b <= n && cnt[rcnt[b]] == val)
			queries.pb(rcnt[b]), ++b;
		if(points.size() != queries.size())
		{
			cout << "NO";
			return 0;
		}
		for(int i = 0; i < points.size(); ++i)
			sol[queries[i]] = pct[points[i]];
	}
	for(int i = 1; i <= n; ++i)
	{
		if(compute(100002 - sol[i].fi) >= sol[i].se)
			ok = 0;
		upd(100002 - sol[i].fi, sol[i].se);
	}
	if(!ok)
	{
		cout << "NO\n";
		return 0;
	}
	cout << "YES\n";
	for(int i = 1; i <= n; ++i)
		cout << sol[i].fi-1 << " " << sol[i].se-1 << '\n';
    return 0;
}


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

#define MOD 1000000007
#define ll long long int
#define vi vector<int>
#define vii vector< vector<int> >
#define PI 3.1415926535897932384626433832795
#define INF 9223372036854775807LL

int cnts[200005];
int cnt2[200005];
pair<int,int> ans[200005];
int from[200005];
int miny[200005];
vector<vector<pair<int,int> > > pointswith (200005,vector<pair<int,int>>());

int main() {
	ios::sync_with_stdio(false);
	cin.tie(NULL);
	int n;
	cin >> n;
	vi arr(n);
	vector<pair<int,int> > points(n);
	for(int i = 0; i < n; i++) {
		int x,y;
		cin >> x >> y;
		cnts[y-x+100001]++;
		points[i] = {y-x+100001,x};
		pointswith[y-x+100000].push_back(points[i]);
	}
	vi w(n);
	for(int i = 0; i < n; i++) {
		cin >> w[i];
		cnt2[w[i]+100001]++;
	}
	for(int i = 0; i <= 200004; i++) {
		if(cnt2[i] != cnts[i]) {
			cout << "NO";
			return 0;
		}
		sort(pointswith[i].begin(),pointswith[i].end());
	}
	sort(points.begin(),points.end());
	for(int i = 0; i < n; i++) {
		ans[i] = pointswith[w[i]+100001][from[w[i]+100001]++];
	}
	for(int i = 0; i < n; i++) {
		auto el = ans[i];
		int x = el.second;
		int y = el.second+el.first-100001;
		if(y < miny[x]) {
			cout << "NO";
			return 0;
		}
		miny[x] = y;
	}
	cout << "YES\n";
	for(int i = 0; i < n; i++) {
		auto el = ans[i];
		cout << el.second << " " << el.second+el.first-100001 << endl;
	}
	return 0;
}


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

#define MOD 1000000007
#define ll long long int
#define vi vector<int>
#define vii vector< vector<int> >
#define PI 3.1415926535897932384626433832795
#define INF 9223372036854775807LL

int cnts[200005];
int cnt2[200005];
pair<int,int> ans[200005];
int from[200005];
vector<vector<pair<int,int> > > pointswith (200005,vector<pair<int,int>>());

int main() {
	ios::sync_with_stdio(false);
	cin.tie(NULL);
	int n;
	cin >> n;
	vi arr(n);
	vector<pair<int,int> > points(n);
	for(int i = 0; i < n; i++) {
		int x,y;
		cin >> x >> y;
		cnts[y-x+100000]++;
		points[i] = {y-x+100000,x};
		pointswith[y-x+100000].push_back(points[i]);
	}
	vi w(n);
	for(int i = 0; i < n; i++) {
		cin >> w[i];
		cnt2[w[i]+100000]++;
	}
	for(int i = 0; i <= 200000; i++) {
		if(cnt2[i] != cnts[i]) {
			cout << "NO";
			return 0;
		}
		sort(pointswith[i].begin(),pointswith[i].end());
	}
	sort(points.begin(),points.end());
	for(int i = 0; i < n; i++) {
		ans[i] = pointswith[w[i]+100000][from[w[i]+100000]++];
	}
	cout << "YES\n";
	for(int i = 0; i < n; i++){
		auto el = ans[i];
		cout << el.second << " " << el.second+el.first-100000 << endl;
	}
	return 0;
}


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

#define MOD 1000000007
#define ll long long int
#define vi vector<int>
#define vii vector< vector<int> >
#define PI 3.1415926535897932384626433832795
#define INF 9223372036854775807LL

int cnts[200105];
int cnt2[200105];
pair<int,int> ans[201005];
int from[200105];
int miny[200105];
vector<vector<pair<int,int> > > pointswith (200105,vector<pair<int,int>>());

int main() {
	ios::sync_with_stdio(false);
	cin.tie(NULL);
	int n;
	cin >> n;
	vi arr(n);
	vector<pair<int,int> > points(n);
	for(int i = 0; i < n; i++) {
		int x,y;
		cin >> x >> y;
		cnts[y-x+100001]++;
		points[i] = {y-x+100001,x};
		pointswith[y-x+100001].push_back(points[i]);
	}
	vi w(n);
	for(int i = 0; i < n; i++) {
		cin >> w[i];
		cnt2[w[i]+100001]++;
	}
	for(int i = 0; i <= 200004; i++) {
		if(cnt2[i] != cnts[i]) {
			cout << "NO";
			return 0;
		}
		sort(pointswith[i].begin(),pointswith[i].end());
	}
	//cout << "a" << endl;
	sort(points.begin(),points.end());
	for(int i = 0; i < n; i++) {
		ans[i] = pointswith[w[i]+100001][from[w[i]+100001]++];
	}
//	cout << "a" << endl;
	for(int i = 0; i < n; i++) {
		auto el = ans[i];
		int x = el.second;
		int y = el.second+el.first-100001;
		if(y < miny[x]) {
			cout << "NO";
			return 0;
		}
		miny[x] = y;
	}
	//cout << "a" << endl;
	cout << "YES\n";
	for(int i = 0; i < n; i++) {
		auto el = ans[i];
		cout << el.second << " " << el.second+el.first-100001 << endl;
	}
	return 0;
}


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

#define MOD 1000000007
#define ll long long int
#define vi vector<int>
#define vii vector< vector<int> >
#define PI 3.1415926535897932384626433832795
#define INF 9223372036854775807LL

int cnts[200005];
int cnt2[200005];
pair<int,int> ans[200005];
int from[200005];
vector<vector<pair<int,int> > > pointswith (200005,vector<pair<int,int>>());

int main() {
	ios::sync_with_stdio(false);
	cin.tie(NULL);
	int n;
	cin >> n;
	vi arr(n);
	vector<pair<int,int> > points(n);
	for(int i = 0; i < n; i++) {
		cin >> points[i].first >> points[i].second;
		cnts[points[i].second-points[i].first+100000]++;
		pointswith[points[i].second-points[i].first+100000].push_back(points[i]);
	}
	vi w(n);
	for(int i = 0; i < n; i++) {
		cin >> w[i];
		cnt2[w[i]+100000]++;
	}
	for(int i = 0; i <= 200000; i++) {
		if(cnt2[i] != cnts[i]) {
			cout << "NO";
			return 0;
		}
		sort(pointswith[i].begin(),pointswith[i].end());
	}
	sort(points.begin(),points.end());
	for(int i = 0; i < n; i++) {
		ans[i] = pointswith[w[i]+100000][from[w[i]+100000]++];
	}
	cout << "YES\n";
	for(int i = 0; i < n; i++){
		auto el = ans[i];
		cout << el.first << " " << el.second << endl;
	}
	return 0;
}


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

#define MOD 1000000007
#define ll long long int
#define vi vector<int>
#define vii vector< vector<int> >
#define PI 3.1415926535897932384626433832795
#define INF 9223372036854775807LL

int cnts[200105];
int cnt2[200105];
pair<int,int> ans[201005];
int from[200105];
int miny[200105];
vector<vector<pair<int,int> > > pointswith (200105,vector<pair<int,int>>());

int main() {
	ios::sync_with_stdio(false);
	cin.tie(NULL);
	int n;
	cin >> n;
	vi arr(n);
	vector<pair<int,int> > points(n);
	for(int i = 0; i < n; i++) {
		int x,y;
		cin >> x >> y;
		cnts[y-x+100001]++;
		points[i] = {y-x+100001,x};
		pointswith[y-x+100000].push_back(points[i]);
	}
	vi w(n);
	for(int i = 0; i < n; i++) {
		cin >> w[i];
		cnt2[w[i]+100001]++;
	}
	for(int i = 0; i <= 200004; i++) {
		if(cnt2[i] != cnts[i]) {
			cout << "NO";
			return 0;
		}
		sort(pointswith[i].begin(),pointswith[i].end());
	}
	sort(points.begin(),points.end());
	for(int i = 0; i < n; i++) {
		ans[i] = pointswith[w[i]+100001][from[w[i]+100001]++];
	}
	for(int i = 0; i < n; i++) {
		auto el = ans[i];
		int x = el.second;
		int y = el.second+el.first-100001;
		if(y < miny[x]) {
			cout << "NO";
			return 0;
		}
		miny[x] = y;
	}
	cout << "YES\n";
	for(int i = 0; i < n; i++) {
		auto el = ans[i];
		cout << el.second << " " << el.second+el.first-100001 << endl;
	}
	return 0;
}


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

#define MOD 1000000007
#define ll long long int
#define vi vector<int>
#define vii vector< vector<int> >
#define PI 3.1415926535897932384626433832795
#define INF 9223372036854775807LL

int cnts[200005];
int cnt2[200005];
pair<int,int> ans[200005];
int from[200005];
int miny[200005];
vector<vector<pair<int,int> > > pointswith (200005,vector<pair<int,int>>());

int main() {
	ios::sync_with_stdio(false);
	cin.tie(NULL);
	int n;
	cin >> n;
	vi arr(n);
	vector<pair<int,int> > points(n);
	for(int i = 0; i < n; i++) {
		int x,y;
		cin >> x >> y;
		cnts[y-x+100000]++;
		points[i] = {y-x+100000,x};
		pointswith[y-x+100000].push_back(points[i]);
	}
	vi w(n);
	for(int i = 0; i < n; i++) {
		cin >> w[i];
		cnt2[w[i]+100000]++;
	}
	for(int i = 0; i <= 200000; i++) {
		if(cnt2[i] != cnts[i]) {
			cout << "NO";
			return 0;
		}
		sort(pointswith[i].begin(),pointswith[i].end());
	}
	sort(points.begin(),points.end());
	for(int i = 0; i < n; i++) {
		ans[i] = pointswith[w[i]+100000][from[w[i]+100000]++];
	}
	for(int i = 0; i < n; i++) {
		auto el = ans[i];
		int x = el.second;
		int y = el.second+el.first-100000;
		if(y < miny[x]) {
			cout << "NO";
			return 0;
		}
		miny[x] = y;
	}
	cout << "YES\n";
	for(int i = 0; i < n; i++) {
		auto el = ans[i];
		cout << el.second << " " << el.second+el.first-100000 << endl;
	}
	return 0;
}


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

#define MOD 1000000007
#define ll long long int
#define vi vector<int>
#define vii vector< vector<int> >
#define PI 3.1415926535897932384626433832795
#define INF 9223372036854775807LL

int cnts[200005];
int cnt2[200005];
pair<int,int> ans[200005];
int from[200005];
vector<vector<pair<int,int> > > pointswith (200005,vector<pair<int,int>>());

int main() {
	ios::sync_with_stdio(false);
	cin.tie(NULL);
	int n;
	cin >> n;
	vi arr(n);
	vector<pair<int,int> > points(n);
	for(int i = 0; i < n; i++) {
		int x,y;
		cin >> x >> y;
		cnts[y-x+100000]++;
		points[i] = {y-x+100000,x};
		pointswith[y-x+100000].push_back(points[i]);
	}
	vi w(n);
	for(int i = 0; i < n; i++) {
		cin >> w[i];
		cnt2[w[i]+100000]++;
	}
	for(int i = 0; i <= 200000; i++) {
		if(cnt2[i] != cnts[i]) {
			cout << "NO";
			return 0;
		}
		sort(pointswith[i].begin(),pointswith[i].end());
	}
	sort(points.begin(),points.end());
	for(int i = 0; i < n; i++) {
		ans[i] = pointswith[w[i]+100000][from[w[i]+100000]++];
	}
	cout << "YES\n";
	for(int i = 0; i < n; i++){
		auto el = ans[i];
		cout << el.first << " " << el.second << endl;
	}
	return 0;
}


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

#define MOD 1000000007
#define ll long long int
#define vi vector<int>
#define vii vector< vector<int> >
#define PI 3.1415926535897932384626433832795
#define INF 9223372036854775807LL

int cnts[200105];
int cnt2[200105];
pair<int,int> ans[201005];
int from[200105];
int miny[200105];
int val[200015];
vector<vector<pair<int,int> > > pointswith (200105,vector<pair<int,int>>());

int main() {
	ios::sync_with_stdio(false);
	cin.tie(NULL);
	int n;
	cin >> n;
	vi arr(n);
	vector<pair<int,int> > points(n);
	for(int i = 0; i < n; i++) {
		int x,y;
		cin >> x >> y;
		cnts[y-x+100001]++;
		points[i] = {y-x+100001,x};
		pointswith[y-x+100001].push_back(points[i]);
	}
	vi w(n);
	for(int i = 0; i < n; i++) {
		cin >> w[i];
		cnt2[w[i]+100001]++;
	}
	for(int i = 0; i <= 200004; i++) {
		if(cnt2[i] != cnts[i]) {
			cout << "NO";
			return 0;
		}
		sort(pointswith[i].begin(),pointswith[i].end());
	}
	//cout << "a" << endl;
	sort(points.begin(),points.end());
	for(int i = 0; i < n; i++) {
		ans[i] = pointswith[w[i]+100001][from[w[i]+100001]++];
	}
//	cout << "a" << endl;
	map<ll,int> answs;
	for(int i = 0; i < n; i++) {
		auto el = ans[i];
		int x = el.second;
		int y = el.second+el.first-100001;
		answs[x*1000000LL+y] = i;
		/*if(y < miny[x]) {
			cout << "NO";
			return 0;
		}
		miny[x] = y;*/
	}
	for(auto el : points) {
		int x = el.second;
		int y = el.second+el.first-100001;
		if(x != 0) {
			if(answs[(x-1)*1000000LL+y] > answs[x*1000000LL+y]) {
				cout << "NO";
				return 0;
			}
		}
		if(y != 0) {
			if(answs[(x)*1000000LL+y-1] > answs[x*1000000LL+y]) {
				cout << "NO";
				return 0;
			}
		}
	}
	//cout << "a" << endl;
	cout << "YES\n";
	for(int i = 0; i < n; i++) {
		auto el = ans[i];
		cout << el.second << " " << el.second+el.first-100001 << endl;
	}
	return 0;
}


/*
ID: Aman Raj
LANG: C++
TASK: prefix
*/
//#include<iostream>
#include <stdio.h>
//#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;
#include<math.h>
typedef  long long int ll;
#include <bits/stdc++.h>
#include <vector>
#include <set>
#include <map>
#include <string>
#include <cstdio>
#include <cstdlib>
#include <climits>
#include <utility>
#include <algorithm>
#include <cmath>
#include <queue>
#include <stack>
#include <iomanip>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
//setbase - cout << setbase (16); cout << 100 << endl; Prints 64
//setfill -   cout << setfill ('x') << setw (5); cout << 77 << endl; prints xxx77
//setprecision - cout << setprecision (14) << f << endl; Prints x.xxxx
//cout.precision(x)  cout<<fixed<<val;  // prints x digits after decimal in val

using namespace std;
using namespace __gnu_pbds;

#define f(i,a,b) for(i=a;i<b;i++)
#define rep(i,n) f(i,0,n)
#define fd(i,a,b) for(i=a;i>=b;i--)
#define pb push_back
#define mp make_pair
#define vi vector< int >
#define vl vector< ll >
#define ss second
#define ff first
//#define ll long long
#define pii pair< int,int >
#define pll pair< ll,ll >
#define sz(a) a.size()
#define inf (1000*1000*1000+5)
#define all(a) a.begin(),a.end()
#define tri pair<int,pii>
#define vii vector<pii>
#define vll vector<pll>
#define viii vector<tri>
#define mod (1000*1000*1000+7)
#define pqueue priority_queue< int >
#define pdqueue priority_queue< int,vi ,greater< int > >
//#define flush fflush(stdout)
#define primeDEN 727999983
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
#include <fstream>
// find_by_order()  // order_of_key
typedef tree<
	int,
	null_type,
	less<int>,
	rb_tree_tag,
	tree_order_statistics_node_update>
	ordered_set;
   bool comp1(pair<pair<ll,ll>,ll> p1, pair<pair<ll,ll>,ll> p2 )
   {
       if(p1.first.first!=p2.first.first)return p1.first.first < p2.first.first;
         return p1.first.second < p2.first.second;
   }
    bool comp2(pair<pair<ll,ll>,ll> p1, pair<pair<ll,ll>,ll> p2 )
   {
       if(p1.first.second!=p2.first.second)return p1.first.second < p2.first.second;
         return p1.first.first < p2.first.first;
   }
    bool comp3(pair<pair<ll,ll>,ll> p1, pair<pair<ll,ll>,ll> p2 )
   {
       return p1.second < p2.second;

   }
   int main()
{    ll n;cin >>n;
     vector<pair<ll,ll> > v(n);
     vector<ll> vw(n);
     set<ll> s;bool ok=true;
     vector<vector<pair<ll,ll> > > vpos(100001),vneg(100001);
     for(ll i=0;i<n;i++)cin>>v[i].first>>v[i].second;
     for(ll i=0;i<n;i++)cin>>vw[i];
     for(auto x:v)
     { ll a=x.second-x.first;s.insert(a);
        if(a>=0)vpos[a].push_back(x);
        else vneg[abs(a)].push_back(x);
    }
    for(auto x:s)
    {
        ll a=x;
        if(a>=0)sort(vpos[a].rbegin(),vpos[a].rend());
        else sort(vneg[abs(a)].rbegin(),vneg[abs(a)].rend());
    }
    vector<pair<pair<ll,ll>,ll> > vans;

    for(ll i=0;i<vw.size();i++)
    { ll d=vw[i];

      if(d>=0)
      { if(vpos[d].size()==0){cout<<"NO";return 0;} vans.push_back({vpos[d].back(),i+1});
         vpos[d].pop_back();

      }
      else
      {d=abs(d);if(vneg[d].size()==0){cout<<"NO";return 0;}  vans.push_back({vneg[d].back(),i+1});
         vneg[d].pop_back();

      }

    }

    //for(auto x:vans)cout<<x.first.first<<" "<<x.first.second<<" "<<x.second<<endl;

  sort(vans.begin(),vans.end(),comp1);
    for(ll i=1;i<vans.size();i++)
    {  if(vans[i].first.second==0)continue;
        if(vans[i].second<vans[i-1].second){ok=false;break;}

    }
    if(ok==false){cout<<"NO";return 0;}
   sort(vans.begin(),vans.end(),comp2);
    for(ll i=1;i<vans.size();i++)
    {  if(vans[i].first.first==0)continue;
        if(vans[i].second<vans[i-1].second){ok=false;break;}

    }
    if(ok==false){cout<<"NO";return 0;}
     sort(vans.begin(),vans.end(),comp3);
     cout<<"YES"<<endl;
     for(auto x:vans)cout<<x.first.first<<" "<<x.first.second<<endl;
    return 0;
 }


/*
ID: Aman Raj
LANG: C++
TASK: prefix
*/
//#include<iostream>
#include <stdio.h>
//#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;
#include<math.h>
typedef  long long int ll;
#include <bits/stdc++.h>
#include <vector>
#include <set>
#include <map>
#include <string>
#include <cstdio>
#include <cstdlib>
#include <climits>
#include <utility>
#include <algorithm>
#include <cmath>
#include <queue>
#include <stack>
#include <iomanip>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
//setbase - cout << setbase (16); cout << 100 << endl; Prints 64
//setfill -   cout << setfill ('x') << setw (5); cout << 77 << endl; prints xxx77
//setprecision - cout << setprecision (14) << f << endl; Prints x.xxxx
//cout.precision(x)  cout<<fixed<<val;  // prints x digits after decimal in val

using namespace std;
using namespace __gnu_pbds;

#define f(i,a,b) for(i=a;i<b;i++)
#define rep(i,n) f(i,0,n)
#define fd(i,a,b) for(i=a;i>=b;i--)
#define pb push_back
#define mp make_pair
#define vi vector< int >
#define vl vector< ll >
#define ss second
#define ff first
//#define ll long long
#define pii pair< int,int >
#define pll pair< ll,ll >
#define sz(a) a.size()
#define inf (1000*1000*1000+5)
#define all(a) a.begin(),a.end()
#define tri pair<int,pii>
#define vii vector<pii>
#define vll vector<pll>
#define viii vector<tri>
#define mod (1000*1000*1000+7)
#define pqueue priority_queue< int >
#define pdqueue priority_queue< int,vi ,greater< int > >
//#define flush fflush(stdout)
#define primeDEN 727999983
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
#include <fstream>
// find_by_order()  // order_of_key
typedef tree<
	int,
	null_type,
	less<int>,
	rb_tree_tag,
	tree_order_statistics_node_update>
	ordered_set;
   bool comp1(pair<pair<ll,ll>,ll> p1, pair<pair<ll,ll>,ll> p2 )
   {
       if(p1.first.first!=p2.first.first)return p1.first.first < p2.first.first;
         return p1.first.second < p2.first.second;
   }
    bool comp2(pair<pair<ll,ll>,ll> p1, pair<pair<ll,ll>,ll> p2 )
   {
       if(p1.first.first!=p2.first.first)return p1.first.second < p2.first.second;
         return p1.first.first < p2.first.first;
   }
    bool comp3(pair<pair<ll,ll>,ll> p1, pair<pair<ll,ll>,ll> p2 )
   {
       return p1.second < p2.second;

   }
   int main()
{    ll n;cin >>n;
     vector<pair<ll,ll> > v(n);
     vector<ll> vw(n);
     set<ll> s;bool ok=true;
     vector<vector<pair<ll,ll> > > vpos(100001),vneg(100001);
     for(ll i=0;i<n;i++)cin>>v[i].first>>v[i].second;
     for(ll i=0;i<n;i++)cin>>vw[i];
     for(auto x:v)
     { ll a=x.second-x.first;s.insert(a);
        if(a>=0)vpos[a].push_back(x);
        else vneg[abs(a)].push_back(x);
    }
    for(auto x:s)
    {
        ll a=x;
        if(a>=0)sort(vpos[a].rbegin(),vpos[a].rend());
        else sort(vneg[abs(a)].rbegin(),vneg[abs(a)].rend());
    }
    vector<pair<pair<ll,ll>,ll> > vans;

    for(ll i=0;i<vw.size();i++)
    { ll d=vw[i];

      if(d>=0)
      { if(vpos[d].size()==0){cout<<"NO";return 0;} vans.push_back({vpos[d].back(),i+1});
         vpos[d].pop_back();

      }
      else
      {d=abs(d);if(vneg[d].size()==0){cout<<"NO";return 0;}  vans.push_back({vneg[d].back(),i+1});
         vneg[d].pop_back();

      }

    }

    //for(auto x:vans)cout<<x.first.first<<" "<<x.first.second<<" "<<x.second<<endl;

  sort(vans.begin(),vans.end(),comp1);
    for(ll i=1;i<vans.size();i++)
    {  if(vans[i].first.second==0)continue;
        if(vans[i].second<vans[i-1].second){ok=false;break;}

    }
    if(ok==false){cout<<"NO";return 0;}
   sort(vans.begin(),vans.end(),comp2);
    for(ll i=1;i<vans.size();i++)
    {  if(vans[i].first.first==0)continue;
        if(vans[i].second<vans[i-1].second){ok=false;break;}

    }
    if(ok==false){cout<<"NO";return 0;}
     sort(vans.begin(),vans.end(),comp3);
     cout<<"YES"<<endl;
     for(auto x:vans)cout<<x.first.first<<" "<<x.first.second<<endl;
    return 0;
 }


#include <bits/stdc++.h>

using namespace std;

typedef pair<int,int>   II;
typedef vector< II >      VII;
typedef vector<int>     VI;
typedef vector<long long>     VLL;
typedef vector< VI >    VVI;
typedef long long int   LL;

#define PB push_back
#define MP make_pair
#define F first
#define S second
#define SZ(a) (int)(a.size())
#define ALL(a) a.begin(),a.end()
#define SET(a,b) memset(a,b,sizeof(a))

#define din(n) int n; scanf("%d",&n)
#define dout(n) printf("%d\n",n)
#define llin(n) long long n; scanf("%lld",&n)
#define llout(n) printf("%lld\n",n)
#define strin(s,l) char s[l]; scanf("%s",s)
#define strout(n) printf("%s\n",n)
#define fast_io ios_base::sync_with_stdio(false);cin.tie(NULL)
#define endl '\n'

#define TRACE

#ifdef TRACE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
        cerr << name << " : " << arg1 << '\n';
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
        const char* comma = strchr(names + 1, ',');cerr.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);
}
#else
#define trace(...)
#endif
bool cmpManh(const std::pair<long long,long long>& l, const std::pair<long long,long long>& r)  {
return ((llabs(l.F) + llabs(l.S)) < (llabs(r.F) + llabs(r.S)));
}

int gcd(int a, int b){
if (a == 0) return b; return gcd(b%a, a);
}

set<int> xx[100001],yy[100001];
int main(void)
{
	din(n);
	std::vector<pair<int,int>> v;
	VI X,Y;
	int minix = 1e6,miniy = 1e6;
	for (int i = 0; i < n; ++i)
	{
		din(x); din(y);
		v.PB(MP(x,y));
		X.PB(x);
		Y.PB(y);
		// minix = min(x,minix);
		// miniy = min(y,miniy);
		xx[x].insert(y);
		yy[y].insert(x);
	}
	VI w;
	sort(ALL(X));
	sort(ALL(Y));
	sort(ALL(v));
	for (int i = 0; i < n; ++i)
	{
		din(x); w.PB(x);
		/* code */
	}
	int ix = 0;
	int iy = 0;
	int currx=X[0],curry=Y[0];
	std::vector<pair<int,int>> ans;
	for (int i = 0; i < n; ++i)
	{
		currx = X[ix];
		curry = X[iy];
		int diff = w[i]; //y-x
		if((binary_search(ALL(v),MP(currx,currx + diff)))){
			xx[currx].erase(currx+diff);
			ans.PB(MP(currx,currx+diff));
			if(xx[currx].size()==0){
				ix++;
			}
		}
		else if(binary_search(ALL(v),MP(curry-diff,curry))){
			yy[curry].erase(curry-diff);
			ans.PB(MP(curry-diff,curry));
			if(yy[curry].size()==0){
				iy++;
			}
		}
		else{
			cout<<"NO"<<endl;
			return 0;
		}
	}
	cout<<"YES"<<endl;
	int sz = ans.size();
	for (int i = 0; i < sz; ++i)
	{
		cout<<ans[i].F<<" "<<ans[i].S<<endl;
		/* code */
	}
    return(0);
}


#include <bits/stdc++.h>

using namespace std;

typedef pair<int,int>   II;
typedef vector< II >      VII;
typedef vector<int>     VI;
typedef vector<long long>     VLL;
typedef vector< VI >    VVI;
typedef long long int   LL;

#define PB push_back
#define MP make_pair
#define F first
#define S second
#define SZ(a) (int)(a.size())
#define ALL(a) a.begin(),a.end()
#define SET(a,b) memset(a,b,sizeof(a))

#define din(n) int n; scanf("%d",&n)
#define dout(n) printf("%d\n",n)
#define llin(n) long long n; scanf("%lld",&n)
#define llout(n) printf("%lld\n",n)
#define strin(s,l) char s[l]; scanf("%s",s)
#define strout(n) printf("%s\n",n)
#define fast_io ios_base::sync_with_stdio(false);cin.tie(NULL)
#define endl '\n'

// #define TRACE

#ifdef TRACE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
        cerr << name << " : " << arg1 << '\n';
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
        const char* comma = strchr(names + 1, ',');cerr.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);
}
#else
#define trace(...)
#endif
bool cmpManh(const std::pair<long long,long long>& l, const std::pair<long long,long long>& r)  {
return ((llabs(l.F) + llabs(l.S)) < (llabs(r.F) + llabs(r.S)));
}

int gcd(int a, int b){
if (a == 0) return b; return gcd(b%a, a);
}

set<int> xx[100001],yy[100001];
int main(void)
{
	din(n);
	std::vector<pair<int,int>> v;
	set<int> X,Y;
	int minix = 1e6,miniy = 1e6;
	for (int i = 0; i < n; ++i)
	{
		din(x); din(y);
		v.PB(MP(x,y));
		X.insert(x);
		Y.insert(y);
		// minix = min(x,minix);
		// miniy = min(y,miniy);
		xx[x].insert(y);
		yy[y].insert(x);
	}
	VI w;
	// sort(ALL(X));
	// sort(ALL(Y));
	sort(ALL(v));
	for (int i = 0; i < n; ++i)
	{
		din(x); w.PB(x);
		/* code */
	}
	int ix = 0;
	int iy = 0;
	auto itx = X.begin();
	auto ity = Y.begin();
	// aut
	int currx=*(itx),curry=*(ity);
	std::vector<pair<int,int>> ans;
	for (int i = 0; i < n; ++i)
	{
		currx = *(itx);
		curry = *(ity);
		trace(currx,curry);
		int diff = w[i]; //y-x
		if((binary_search(ALL(v),MP(currx,currx + diff)))){
			xx[currx].erase(currx+diff);
			ans.PB(MP(currx,currx+diff));
			trace(xx[currx].size());
			if(xx[currx].size()<=0){
				itx++;
				trace("lol1");
			}
		}
		else if(binary_search(ALL(v),MP(curry-diff,curry))){
			yy[curry].erase(curry-diff);
			ans.PB(MP(curry-diff,curry));
			trace(yy[curry].size());
			if(yy[curry].size()<=0){
				ity++;
				trace("lol1");
			}
		}
		else{
			cout<<"NO"<<endl;
			return 0;
		}
	}
	cout<<"YES"<<endl;
	int sz = ans.size();
	for (int i = 0; i < sz; ++i)
	{
		cout<<ans[i].F<<" "<<ans[i].S<<endl;
		/* code */
	}
    return(0);
}


#include <bits/stdc++.h>

using namespace std;

typedef pair<int,int>   II;
typedef vector< II >      VII;
typedef vector<int>     VI;
typedef vector<long long>     VLL;
typedef vector< VI >    VVI;
typedef long long int   LL;

#define PB push_back
#define MP make_pair
#define F first
#define S second
#define SZ(a) (int)(a.size())
#define ALL(a) a.begin(),a.end()
#define SET(a,b) memset(a,b,sizeof(a))

#define din(n) int n; scanf("%d",&n)
#define dout(n) printf("%d\n",n)
#define llin(n) long long n; scanf("%lld",&n)
#define llout(n) printf("%lld\n",n)
#define strin(s,l) char s[l]; scanf("%s",s)
#define strout(n) printf("%s\n",n)
#define fast_io ios_base::sync_with_stdio(false);cin.tie(NULL)
#define endl '\n'

// #define TRACE

#ifdef TRACE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
        cerr << name << " : " << arg1 << '\n';
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
        const char* comma = strchr(names + 1, ',');cerr.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);
}
#else
#define trace(...)
#endif
bool cmpManh(const std::pair<long long,long long>& l, const std::pair<long long,long long>& r)  {
return ((llabs(l.F) + llabs(l.S)) < (llabs(r.F) + llabs(r.S)));
}

int gcd(int a, int b){
if (a == 0) return b; return gcd(b%a, a);
}
const int N = 1e5+5;
set<int> xx[100001],yy[100001];
int main(void)
{
	din(n);
	std::vector<pair<int,int>> v;
	set<int> X,Y;
	map <int,set<pair<int,int>> > mp;
	int minix = 1e6,miniy = 1e6;
	for (int i = 0; i < n; ++i)
	{
		din(x); din(y);
		v.PB(MP(x,y));
		X.insert(x);
		Y.insert(y);
		// minix = min(x,minix);
		// miniy = min(y,miniy);
		xx[x].insert(y);
		yy[y].insert(x);
		mp[y-x].insert(MP(x,y));
	}
	VI w;
	// sort(ALL(X));
	// sort(ALL(Y));
	sort(ALL(v));
	std::vector<pair<int,int>> pp(N);
	for (int i = 0; i < n; ++i)
	{
		din(x); w.PB(x);
		if(mp[x].empty()){
			cout<<"NO"<<endl;
			return 0;
		}
		pp[i] = *(mp[x].begin());
		mp[x].erase(mp[x].begin());
	}
	int lastx = 0;
	int lasty = 0;
	for (int i = 1; i < n; ++i)
	{
		int x = pp[i].F;
		int y = pp[i].S;
		trace(lastx,lasty,x,y);
		if(!(x>lastx || y>lasty)){
			cout<<"NO"<<endl;
			return 0;
		}
		lasty = y;
		lastx = x;

	}
	cout<<"YES"<<endl;
	// int sz = ans.size();
	for (int i = 0; i < n; ++i)
	{
		cout<<pp[i].F<<" "<<pp[i].S<<endl;
		/* code */
	}
    return(0);
}


import java.io.*;
import java.math.BigInteger;
import java.util.*;

public class C {

    static BufferedReader in;
    static PrintWriter out;
    static StringTokenizer tok;

    public static void main(String[] args) throws IOException {
        try {
            in = new BufferedReader(new FileReader("quarth.in"));
            out = new PrintWriter(new File("quarth.out"));
        } catch (Exception e) {
            in = new BufferedReader(new InputStreamReader(System.in));
            out = new PrintWriter(new OutputStreamWriter(System.out));
        }
        tok = new StringTokenizer("");
        new C().solve();
        out.flush();
        out.close();
    }

    String nextTok() throws IOException {
        if (!tok.hasMoreTokens()) {
            tok = new StringTokenizer(in.readLine());
        }
        return tok.nextToken();
    }

    int nextInt() throws IOException {
        return Integer.parseInt(nextTok());
    }

    long nextLong() throws IOException {
        return Long.parseLong(nextTok());
    }

    double nextDouble() throws IOException {
        return Double.parseDouble(nextTok());
    }

    static class Pair implements Comparable<Pair>  {

        int x;
        int y;
        int z;

        Pair ( int x, int y, int z) {
            this.x = x;
            this.y = y;
            this.z = z;

        }

        @Override
        public int compareTo(Pair o) {
            if (x < o.x) return -1;
            if (x > o.x) return 1;
            if (y < o.y) return -1;
            if (y > o.y) return 1;
            if (z < o.z) return -1;
            if (z > o.z) return 1;
            return 0;
        }
    }

    void solve() throws IOException {
        int n = nextInt();

        Pair[] v = new Pair[n];
        Pair[] w = new Pair[n];
        for (int i = 0; i < n; i++) {
            int a = nextInt();
            int b = nextInt();
            v[i] = new Pair(b-a,a,b);
        }
        for (int i = 0; i < n; i++) {
            w[i] = new Pair(nextInt(),i+1,0);
        }
        Arrays.sort(v);
        Arrays.sort(w);
        Pair[] ans = new Pair[n];
//        ArrayList<Pair> ans = new ArrayList<Pair>();
        for (int i = 0; i < n; i++) {
            if (v[i].x == w[i].x) {
                ans[i] = new Pair(w[i].y,v[i].y,v[i].z);
            } else {
                System.out.println("NO");
                return;
            }
        }
        Arrays.sort(ans);
        System.out.println("YES");
        for (int i = 0; i < n; i++) {
            System.out.println(ans[i].y+" "+ans[i].z);
        }
    }

    private BigInteger catalan (int i) {
        return factorial(2 * i).divide((factorial(i + 1).multiply(factorial(i))));
    }

    private BigInteger factorial (int i) {
        BigInteger n = BigInteger.valueOf(i);
        if (i == 0) {
            return new BigInteger("1");
        }
        while (--i > 0) {
            n = n.multiply(BigInteger.valueOf(i));
        }
        return n;
    }
}


import java.io.*;
import java.math.BigInteger;
import java.util.*;

public class C {

    static BufferedReader in;
    static PrintWriter out;
    static StringTokenizer tok;

    public static void main(String[] args) throws IOException {
        try {
            in = new BufferedReader(new FileReader("quarth.in"));
            out = new PrintWriter(new File("quarth.out"));
        } catch (Exception e) {
            in = new BufferedReader(new InputStreamReader(System.in));
            out = new PrintWriter(new OutputStreamWriter(System.out));
        }
        tok = new StringTokenizer("");
        new C().solve();
        out.flush();
        out.close();
    }

    String nextTok() throws IOException {
        if (!tok.hasMoreTokens()) {
            tok = new StringTokenizer(in.readLine());
        }
        return tok.nextToken();
    }

    int nextInt() throws IOException {
        return Integer.parseInt(nextTok());
    }

    long nextLong() throws IOException {
        return Long.parseLong(nextTok());
    }

    double nextDouble() throws IOException {
        return Double.parseDouble(nextTok());
    }

    static class Pair implements Comparable<Pair>  {

        int x;
        int y;

        Pair ( int x, int y) {
            this.x = x;
            this.y = y;
        }

        @Override
        public int compareTo(Pair o) {
            if (x < o.x) return -1;
            if (x > o.x) return 1;
            if (y < o.y) return -1;
            if (y > o.y) return 1;
            return 0;
        }
    }

    void solve() throws IOException {
        int n = nextInt();
        Map<Integer,TreeSet<Pair>> map = new HashMap<Integer, TreeSet<Pair>>();

        for (int i = 0; i < n; i++) {
            int a = nextInt();
            int b = nextInt();
            if (map.containsKey(b-a)) {
                map.get(b - a).add(new Pair(a, b));
            } else {
                map.put(b-a,new TreeSet<Pair>());
                map.get(b - a).add(new Pair(a, b));
            }
        }
//        for (Map.Entry<Integer,ArrayList<Pair>> e: map.entrySet()) {
//            Collections.sort(map.get(e.getKey()));
//        }

        int x[] = new int[n];
        int y[] = new int[n];
        for (int i = 0; i < n; i++) {
            int w = nextInt();
            if (!map.containsKey(w)) {
                System.out.println("NO");
                return;
            }

            if (map.get(w).size() == 0) {
                System.out.println("NO");
                return;
            }
            x[i] = map.get(w).first().x;
            y[i] = map.get(w).pollFirst().y;
        }

        TreeMap<Integer, Integer> tree = new TreeMap<Integer, Integer>();

        for (int i = 0; i < n; i++) {
            Integer h = tree.higherKey(x[i]-1);
            if (h != null && tree.get(h) >= y[i]) {
                System.out.println("NO");
                return;
            }

            while (true) {
                Integer l = tree.lowerKey(x[i] + 1);
                if (l != null && tree.get(l) <= y[i]) {
                    tree.remove(l);
                } else {
                    break;
                }
            }
            tree.put(x[i],y[i]);
        }

        out.println("YES");
        for (int i = 0; i < n; ++i) {
            out.println(x[i] + " " + y[i]);
        }

    }

    private BigInteger catalan (int i) {
        return factorial(2 * i).divide((factorial(i + 1).multiply(factorial(i))));
    }

    private BigInteger factorial (int i) {
        BigInteger n = BigInteger.valueOf(i);
        if (i == 0) {
            return new BigInteger("1");
        }
        while (--i > 0) {
            n = n.multiply(BigInteger.valueOf(i));
        }
        return n;
    }
}


import java.io.BufferedReader;
import java.io.Reader;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashMap;
import java.util.Scanner;
import java.util.TreeSet;

/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */

/**
 *
 * @author hitarthk
 */
public class C_331_C {
    public static void main(String[] args) {
        Scanner in=new Scanner(System.in);
        HashMap<Integer,TreeSet<Pair>> h=new HashMap<>();
        int n=in.nextInt();
        int offset=100000;
        a=new long[200005];
        tree=new long[4*200005];
        Pair[] p=new Pair[n];
        for(int i=0;i<n;i++){
            int x=in.nextInt();
            int y=in.nextInt();

            if(h.get(y-x)==null){
                h.put(y-x, new TreeSet<Pair>());
            }
            h.get(y-x).add(new Pair(x, y));
        }
        int[] w=new int[n];
        for(int i=0;i<n;i++){
            w[i]=in.nextInt();
        }

        boolean check=true;
        for(int i=0;i<n;i++){
            if(h.get(w[i])==null || h.get(w[i]).isEmpty()){
                check=false;
                break;
            }
            Pair cur=h.get(w[i]).first();
            long q=query(1, 0, 200004, w[i]+offset+1, 200004, tree, a);
            if(cur.x<q){
                check=false;
                break;
            }
            a[w[i]+offset]=cur.x;
            update(1, 0, 200004, w[i]+offset, tree, a);
            p[i]=cur;
            h.get(w[i]).remove(cur);
        }
        if(check) {
            System.out.println("YES");
            for(int i=0;i<n;i++){
                System.out.println(p[i].x+" "+p[i].y);
            }
        }
        else{
            System.out.println("NO");
        }
    }

    static class Pair implements Comparable<Pair>{
        int id;
        int x;
        int y;
        public Pair(int x,int y){
            this.x=x;
            this.y=y;
        }
        @Override
        public int compareTo(Pair o) {
        //    throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
            return this.x-o.x;
        }
        public String toString(){
            return this.x+" "+this.y;
        }
    }

    static long[] tree;
    static long[] a;

    public static void build(int node, int s, int e, long[] tree, long[] a) {
        if (s == e) {
            tree[node] = a[s];
        } else {
            int mid = (s + e) >> 1;
            build(2 * node, s, mid, tree, a);
            build(2 * node + 1, mid + 1, e, tree, a);
            tree[node] = merge(tree[2 * node], tree[2 * node + 1]);
        }

    }

    public static void update(int node, int s, int e, int p, long[] tree, long[] a) {
        if (s == e) {
            tree[node]=a[p];
            return;
        }
        int mid = (s + e) >> 1;
        if (p <= mid) {
            update(2 * node, s, mid, p, tree, a);
        } else {
            update(2 * node + 1, mid + 1, e, p, tree, a);
        }
        tree[node] = merge(tree[2 * node], tree[2 * node + 1]);
    }

    public static long query(int node, int s, int e, int l, int r, long[] tree, long[] a) {
        if (s == l && e == r) {
            return tree[node];
        }
        int mid = (s + e) >> 1;
        if (r <= mid) {
            //System.out.println(l+" "+r);
            return query(2 * node, s, mid, l, r, tree, a);
        }
        if (l > mid) {
            return query(2 * node + 1, mid + 1, e, l, r, tree, a);
        }
        return merge(query(2 * node, s, mid, l, mid, tree, a), query(2 * node + 1, mid + 1, e, mid + 1, r, tree, a));
    }

    public static long merge(long l, long r) {
        return Math.max(l, r);
    }

}


import java.io.BufferedReader;
import java.io.Reader;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashMap;
import java.util.Scanner;
import java.util.TreeSet;

/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */

/**
 *
 * @author hitarthk
 */
public class C_331_C {
    public static void main(String[] args) {
        Scanner in=new Scanner(System.in);
        HashMap<Integer,TreeSet<Pair>> h=new HashMap<>();
        int n=in.nextInt();
        int offset=100000;
        a=new long[200005];
        tree=new long[4*200005];
        b=new long[200005];
        Arrays.fill(b,Long.MIN_VALUE);

        ytree=new long[4*200005];
        build(1, 0, 200004, ytree, b);
        Pair[] p=new Pair[n];
        for(int i=0;i<n;i++){
            int x=in.nextInt();
            int y=in.nextInt();

            if(h.get(y-x)==null){
                h.put(y-x, new TreeSet<Pair>());
            }
            h.get(y-x).add(new Pair(x, y));
        }
        int[] w=new int[n];
        for(int i=0;i<n;i++){
            w[i]=in.nextInt();
        }

        boolean check=true;
        for(int i=0;i<n;i++){
            if(h.get(w[i])==null || h.get(w[i]).isEmpty()){
                check=false;
                break;
            }
            Pair cur=h.get(w[i]).first();
            long q1=query(1, 0, 200004, w[i]+offset+1, 200004, tree, a);
            long q2=query(1, 0, 200004, 0, w[i]+offset-1, ytree, b);
            System.out.println(q1+" "+q2+" "+cur.x+" "+cur.y);
            if(cur.x<q1 || cur.y<=q2){
                check=false;
                break;
            }
            a[w[i]+offset]=cur.x;
            b[w[i]+offset]=cur.y;
            update(1, 0, 200004, w[i]+offset, tree, a);
            update(1, 0, 200004, w[i]+offset, ytree, b);
            p[i]=cur;
            h.get(w[i]).remove(cur);
        }
        if(check) {
            System.out.println("YES");
            for(int i=0;i<n;i++){
                System.out.println(p[i].x+" "+p[i].y);
            }
        }
        else{
            System.out.println("NO");
        }
    }

    static class Pair implements Comparable<Pair>{
        int id;
        int x;
        int y;
        public Pair(int x,int y){
            this.x=x;
            this.y=y;
        }
        @Override
        public int compareTo(Pair o) {
        //    throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
            return this.x-o.x;
        }
        public String toString(){
            return this.x+" "+this.y;
        }
    }

    static long[] tree;
    static long[] a;
    static long[] b;
    static long[] ytree;
    public static void build(int node, int s, int e, long[] tree, long[] a) {
        if(s>e){
            return;
        }
        if (s == e) {
            tree[node] = a[s];
        } else {
            int mid = (s + e) >> 1;
            build(2 * node, s, mid, tree, a);
            build(2 * node + 1, mid + 1, e, tree, a);
            tree[node] = merge(tree[2 * node], tree[2 * node + 1]);
        }

    }

    public static void update(int node, int s, int e, int p, long[] tree, long[] a) {
        if (s == e) {
            tree[node]=a[p];
            return;
        }
        int mid = (s + e) >> 1;
        if (p <= mid) {
            update(2 * node, s, mid, p, tree, a);
        } else {
            update(2 * node + 1, mid + 1, e, p, tree, a);
        }
        tree[node] = merge(tree[2 * node], tree[2 * node + 1]);
    }

    public static long query(int node, int s, int e, int l, int r, long[] tree, long[] a) {
        if (s == l && e == r) {
            return tree[node];
        }
        int mid = (s + e) >> 1;
        if (r <= mid) {
            //System.out.println(l+" "+r);
            return query(2 * node, s, mid, l, r, tree, a);
        }
        if (l > mid) {
            return query(2 * node + 1, mid + 1, e, l, r, tree, a);
        }
        return merge(query(2 * node, s, mid, l, mid, tree, a), query(2 * node + 1, mid + 1, e, mid + 1, r, tree, a));
    }

    public static long merge(long l, long r) {
        return Math.max(l, r);
    }

}


import java.io.BufferedReader;
import java.io.Reader;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashMap;
import java.util.Scanner;
import java.util.TreeSet;

/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */

/**
 *
 * @author hitarthk
 */
public class C_331_C {
    public static void main(String[] args) {
        Scanner in=new Scanner(System.in);
        HashMap<Integer,TreeSet<Pair>> h=new HashMap<>();
        int n=in.nextInt();
        Pair[] p=new Pair[n];
        for(int i=0;i<n;i++){
            int x=in.nextInt();
            int y=in.nextInt();

            if(h.get(y-x)==null){
                h.put(y-x, new TreeSet<>());
            }
            h.get(y-x).add(new Pair(x, y));
        }
        int[] w=new int[n];
        for(int i=0;i<n;i++){
            w[i]=in.nextInt();
        }
        int minx=0;
        int miny=0;
        boolean check=true;
        //System.out.println(h);
        for(int i=0;i<n;i++){
            if(h.get(w[i])==null || h.get(w[i]).isEmpty()){
                check=false;
                break;
            }
            //System.out.println(h);
            Pair cur=h.get(w[i]).first();
            if(cur.x>=minx || cur.y>=miny){
                p[i]=cur;
            }
            else{
                check=false;
                break;
            }
            if(cur.x>minx){
                minx=cur.x;
            }
            if(cur.y>miny){
                miny=cur.y;
            }
            h.get(w[i]).remove(cur);
        }

        //System.out.println(Arrays.toString(p));
        if(check){
            System.out.println("YES");
        for(int i=0;i<n;i++){
            System.out.println(p[i].x+" "+p[i].y+" ");
        }}
        else{
            System.out.println("NO");
        }
    }

    static class Pair implements Comparable<Pair>{
        int id;
        int x;
        int y;
        public Pair(int x,int y){
            this.x=x;
            this.y=y;
        }
        @Override
        public int compareTo(Pair o) {
        //    throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
            return this.x-o.x;
        }
        public String toString(){
            return this.x+" "+this.y;
        }
    }

}


import java.io.BufferedReader;
import java.io.Reader;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashMap;
import java.util.Scanner;
import java.util.TreeSet;

/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */

/**
 *
 * @author hitarthk
 */
public class C_331_C {
    public static void main(String[] args) {
        Scanner in=new Scanner(System.in);
        HashMap<Integer,TreeSet<Pair>> h=new HashMap<>();
        int n=in.nextInt();
        Pair[] p=new Pair[n];
        for(int i=0;i<n;i++){
            int x=in.nextInt();
            int y=in.nextInt();

            if(h.get(y-x)==null){
                h.put(y-x, new TreeSet<Pair>());
            }
            h.get(y-x).add(new Pair(x, y));
        }
        int[] w=new int[n];
        for(int i=0;i<n;i++){
            w[i]=in.nextInt();
        }
        int minx=0;
        int miny=0;
        boolean check=true;
        //System.out.println(h);
        for(int i=0;i<n;i++){
            if(h.get(w[i])==null || h.get(w[i]).isEmpty()){
                check=false;
                break;
            }
            //System.out.println(h);
            Pair cur=h.get(w[i]).first();
            if(cur.x>=minx || cur.y>=miny){
                p[i]=cur;
            }
            else{
                check=false;
                break;
            }
            if(cur.x>minx){
                minx=cur.x;
            }
            if(cur.y>miny){
                miny=cur.y;
            }
            h.get(w[i]).remove(cur);
        }

        //System.out.println(Arrays.toString(p));
        if(check){
            System.out.println("YES");
        for(int i=0;i<n;i++){
            System.out.println(p[i].x+" "+p[i].y+" ");
        }}
        else{
            System.out.println("NO");
        }
    }

    static class Pair implements Comparable<Pair>{
        int id;
        int x;
        int y;
        public Pair(int x,int y){
            this.x=x;
            this.y=y;
        }
        @Override
        public int compareTo(Pair o) {
        //    throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
            return this.x-o.x;
        }
        public String toString(){
            return this.x+" "+this.y;
        }
    }

}