#include <vector>
#include <iostream>
#include <sstream>
#include <unordered_map>
#include <deque>
#include <algorithm>
using namespace std;

template <typename T, typename C = vector<T>>
C ReadSequence()
{
  string line;
  C res;
  T tmp;
  getline(cin, line);
  istringstream stream(line);
  while (stream >> tmp)
    res.push_back(tmp);

  return res;
}

template <typename T>
T Read()
{
  string line;
  T tmp;
  getline(cin, line);
  istringstream stream(line);
  stream >> tmp;
  return tmp;
}

template <typename T>
void Fill(vector<T>* r, T v = 0)
{
  for (size_t i = 0; i < r->size(); ++i)
    (*r)[i] = v;
}

vector<int> rect;
int dimX = 0;
int dimY = 0;

bool IsValid()
{
  for (int i = 0; i < dimY; ++i)
  {
    for (int j = 0; j < dimX; ++j)
    {
      int cur = rect[i*(dimX+1)+j];
      if (cur > rect[i*(dimX+1)+j+1] || cur > rect[(i+1)*(dimX+1)+j] || cur > rect[(i+1)*(dimX+1)+j+1])
      {
        return false;
      }
    }
  }
  return true;
}

unordered_map<int, deque<int>> mm;

int main(int argc, char** argv)
{
  int n = Read<int>();

  int a, b;
  vector<pair<int, int>> pts(n);
  unordered_map<int, int> ptsDiff;
  for (int i = 0; i < n; ++i)
  {
    cin >> a; cin >> b;
    dimX = max(a, dimX);
    dimY = max(b, dimY);
    string tmp;
    getline(cin, tmp);
    auto p = make_pair(a, b);
    mm[b - a].push_back(i);
    pts[i] = p;

    ptsDiff[b-a] += 1;
  }

  vector<int> w = ReadSequence<int>();

  unordered_map<int, int> wCount;
  for (int x : w)
  {
    wCount[x] += 1;
  }

  for (auto& kv : ptsDiff)
  {
    int diff = kv.first;
    int count = kv.second;

    auto it = wCount.find(diff);
    if (it == wCount.end() || it->second != count)
    {
      cout << "NO" << endl;
      return 0;
    }
  }

  for (auto& kv : mm)
  {
    auto& p = kv.second;
    sort(p.begin(), p.end(), [&](int lhs, int rhs)
    {
      if (pts[lhs].first == pts[rhs].first)
        return pts[lhs].second < pts[rhs].second;

      return pts[lhs].first < pts[rhs].first;
    });
  }

  rect.resize((1+dimX) * (1+dimY));
  Fill(&rect, INT_MAX);

  vector<int> res;

  for (int i = 0; i < (int)w.size(); ++i)
  {
    auto it = mm.find(w[i]);
    if (it == mm.end() || it->second.empty())
    {
      cout << "NO" << endl;
      return 0;
    }

    int idx = it->second.front();
    it->second.pop_front();
    res.push_back(idx);
    auto pt = pts[idx];
    rect[pt.second * (dimX+1) + pt.first] = i + 1;
  }

  if (!IsValid())
  {
    cout << "NO" << endl;
    return 0;
  }

  cout << "YES" << endl;
  for (auto& d : res)
  {
    cout << pts[d].first << " " << pts[d].second << endl;
  }

}


#include <iostream>
#include <unordered_map>
#include <algorithm>
#include <queue>
#include <vector>
#include <sstream>
#define fr(i,n) for(i = 0;i<(n);++i)

using namespace std;
typedef pair<int,int> pt;
pt *coords;
class Comp {
public:
    bool operator()(int x, int y){
        pt a = coords[x], b = coords[y];
        if(a.first < b.first)
            return false;
        else if(a.first == b.first){
            if(a.second < b.second){
                return false;
            }
        }
        return true;
    }
};

class CompPt {
public:
    bool operator()(pt a, pt b){
        if(a.first < b.first)
            return false;
        else if(a.first == b.first){
            if(a.second < b.second){
                return false;
            }
        }
        return true;
    }
};

typedef priority_queue<int,vector<int>,Comp> pq;

int main(){
    int i,j,k,n,m;
    unordered_map<int, vector<int>> w;
    unordered_map<int, pq> cc;
    unordered_map<int, int> cnt;

    cin>>n;
    coords = new pt[n];

    fr(i,n){
        int x,y;
        cin>>x>>y;
        coords[i] = make_pair(x,y);
    }

    int wi[n];

    fr(i,n){
        int v;
        cin>>v;
        w[v].push_back(i+1);
        cnt[v]++;
        wi[i] = v;
    }

    fr(i,n){
        int d = coords[i].second - coords[i].first;
        if(cnt.find(d) != cnt.end()){
            cnt[d]--;
            cc[d].push(i);
        } else {
            cout<<"NO";
            return 0;
        }
    }

    stringstream res;

    res<<"YES\n";

    int num[n];
    CompPt comp;
    //sort(coords, coords+n,comp);
    fr(i,n){
        int curr = cc[wi[i]].top();
        cc[wi[i]].pop();
        num[curr] = i+1;
        res<<coords[curr].first<<" "<<coords[curr].second<<"\n";
    }

    /*unordered_map<int,unordered_map<int,int>> p;

    fr(i,n){
        pt curr = coords[i];
        int x1 = curr.first+1, y1 = curr.second + 1;
        if(p[curr.first+1].find([curr.second]) != p[curr.first].end()){

        }
    }*/
    cout<<res.str();
    return 0;

}


#include <iostream>
#include <unordered_map>
#include <queue>
#include <vector>
#include <sstream>
#define fr(i,n) for(i = 0;i<(n);++i)

using namespace std;
typedef pair<int,int> pt;

class Comp {
public:
    bool operator()(pt a, pt b){
        if(a.second < b.second)
            return false;
        else if(a.second == b.second){
            if(a.first < b.first){
                return false;
            }
        }
        return true;
    }
};

typedef priority_queue<pt,vector<pt>,Comp> pq;

int main(){
    int i,j,k,n,m;
    unordered_map<int, vector<int>> w;
    unordered_map<int, pq> cc;
    unordered_map<int, int> cnt;

    cin>>n;
    pt coords[n];

    fr(i,n){
        int x,y;
        cin>>x>>y;
        coords[i] = make_pair(x,y);
    }

    int wi[n];

    fr(i,n){
        int v;
        cin>>v;
        w[v].push_back(i+1);
        cnt[v]++;
        wi[i] = v;
    }

    fr(i,n){
        int d = coords[i].second - coords[i].first;
        if(cnt.find(d) != cnt.end()){
            cnt[d]--;
            cc[d].push(coords[i]);
        } else {
            cout<<"NO";
            return 0;
        }
    }

    stringstream res;

    res<<"YES\n";
    unordered_map<int,int> p;
    fr(i,n){
        pt curr = cc[wi[i]].top();
        cc[wi[i]].pop();
        if(p.find(curr.second) != p.end() && curr.first < p[curr.second]){
            cout<<"NO";
            return 0;
        }
        p[curr.second] = curr.first;
        res<<curr.first<<" "<<curr.second<<"\n";
    }
    cout<<res.str();
    return 0;

}


#include <iostream>
#include <unordered_map>
#include <queue>
#include <vector>
#include <sstream>
#define fr(i,n) for(i = 0;i<(n);++i)

using namespace std;
typedef pair<int,int> pt;

class Comp {
public:
    bool operator()(pt a, pt b){
        if(a.second < b.second)
            return false;
        else if(a.second == b.second){
            if(a.first < b.first){
                return false;
            }
        }
        return true;
    }
};

typedef priority_queue<pt,vector<pt>,Comp> pq;

int main(){
    int i,j,k,n,m;
    unordered_map<int, vector<int>> w;
    unordered_map<int, pq> cc;
    unordered_map<int, int> cnt;

    cin>>n;
    pt coords[n];

    fr(i,n){
        int x,y;
        cin>>x>>y;
        coords[i] = make_pair(x,y);
    }

    int wi[n];

    fr(i,n){
        int v;
        cin>>v;
        w[v].push_back(i+1);
        cnt[v]++;
        wi[i] = v;
    }

    fr(i,n){
        int d = coords[i].second - coords[i].first;
        if(cnt.find(d) != cnt.end()){
            cnt[d]--;
            cc[d].push(coords[i]);
        } else {
            cout<<"NO";
            return 0;
        }
    }

    stringstream res;

    res<<"YES\n";
    pt maxX = make_pair(0,0), maxY = make_pair(0,0);

    fr(i,n){
        pt curr = cc[wi[i]].top();
        cc[wi[i]].pop();
        if(curr.first < maxX.first && curr.second < maxY.second){
            cout<<"NO";
            return 0;
        } else if((curr.first < maxX.first && curr.second == maxY.second) || (curr.second < maxY.second && curr.first == maxX.first)){
            cout<<"NO";
            return 0;
        }

        if(curr.first >= maxX.first){
            maxX = curr;
        }
        if(curr.second >= maxY.second){
            maxY = curr;
        }

        res<<curr.first<<" "<<curr.second<<"\n";
    }
    cout<<res.str();
    return 0;

}


#include <iostream>
#include <unordered_map>
#include <queue>
#include <vector>
#include <sstream>
#define fr(i,n) for(i = 0;i<(n);++i)

using namespace std;
typedef pair<int,int> pt;

class Comp {
public:
    bool operator()(pt a, pt b){
        if(a.second < b.second)
            return false;
        else if(a.second == b.second){
            if(a.first < b.first){
                return false;
            }
        }
        return true;
    }
};

typedef priority_queue<pt,vector<pt>,Comp> pq;

int main(){
    int i,j,k,n,m;
    unordered_map<int, vector<int>> w;
    unordered_map<int, pq> cc;
    unordered_map<int, int> cnt;

    cin>>n;
    pt coords[n];

    fr(i,n){
        int x,y;
        cin>>x>>y;
        coords[i] = make_pair(x,y);
    }

    int wi[n];

    fr(i,n){
        int v;
        cin>>v;
        w[v].push_back(i+1);
        cnt[v]++;
        wi[i] = v;
    }

    fr(i,n){
        int d = coords[i].second - coords[i].first;
        if(cnt.find(d) != cnt.end()){
            cnt[d]--;
            cc[d].push(coords[i]);
        } else {
            cout<<"NO";
            return 0;
        }
    }

    stringstream res;

    res<<"YES\n";
    pt maxX = make_pair(0,0), maxY = make_pair(0,0);
    int val[2] = {0};
    fr(i,n){
        pt curr = cc[wi[i]].top();
        cc[wi[i]].pop();
        if(curr.first < maxX.first && curr.second < maxY.second){
            cout<<"NO";
            return 0;
        }

        if(curr.first >= maxX.first){
            maxX = curr;
            val[0] = i+1;
        }
        if(curr.second >= maxY.second){
            maxY = curr;
            val[1] = i+1;
        }

        res<<curr.first<<" "<<curr.second<<"\n";
    }
    cout<<res.str();
    return 0;

}


#include <iostream>
#include <unordered_map>
#include <algorithm>
#include <queue>
#include <vector>
#include <sstream>
#define fr(i,n) for(i = 0;i<(n);++i)

using namespace std;
typedef pair<int,int> pt;
pt *coords;
class Comp {
public:
    bool operator()(int x, int y){
        pt a = coords[x], b = coords[y];
        if(a.first < b.first)
            return false;
        else if(a.first == b.first){
            if(a.second < b.second){
                return false;
            }
        }
        return true;
    }
};

class CompPt {
public:
    bool operator()(pt a, pt b){
        if(a.first < b.first)
            return false;
        else if(a.first == b.first){
            if(a.second < b.second){
                return false;
            }
        }
        return true;
    }
};

typedef priority_queue<int,vector<int>,Comp> pq;

int main(){
    int i,j,k,n,m;
    unordered_map<int, vector<int>> w;
    unordered_map<int, pq> cc;
    unordered_map<int, int> cnt;

    cin>>n;
    coords = new pt[n];

    fr(i,n){
        int x,y;
        cin>>x>>y;
        coords[i] = make_pair(x,y);
    }

    int wi[n];

    fr(i,n){
        int v;
        cin>>v;
        w[v].push_back(i+1);
        cnt[v]++;
        wi[i] = v;
    }

    fr(i,n){
        int d = coords[i].second - coords[i].first;
        if(cnt.find(d) != cnt.end()){
            cnt[d]--;
            cc[d].push(i);
        } else {
            cout<<"NO";
            return 0;
        }
    }

    stringstream res;

    res<<"YES\n";

    int num[n];
    CompPt comp;
    sort(coords, coords+n,comp);
    fr(i,n){
        int curr = cc[wi[i]].top();
        cc[wi[i]].pop();
        num[curr] = i+1;
        res<<coords[curr].first<<" "<<coords[curr].second<<"\n";
    }

    /*unordered_map<int,unordered_map<int,int>> p;

    fr(i,n){
        pt curr = coords[i];
        int x1 = curr.first+1, y1 = curr.second + 1;
        if(p[curr.first+1].find([curr.second]) != p[curr.first].end()){

        }
    }*/
    cout<<res.str();
    return 0;

}


#include <iostream>
#include <unordered_map>
#include <queue>
#include <vector>
#include <sstream>
#define fr(i,n) for(i = 0;i<(n);++i)

using namespace std;
typedef pair<int,int> pt;

class Comp {
public:
    bool operator()(pt a, pt b){
        if(a.first < b.first)
            return false;
        else if(a.first == b.first){
            if(a.second < b.second){
                return false;
            }
        }
        return true;
    }
};

typedef priority_queue<pt,vector<pt>,Comp> pq;

int main(){
    int i,j,k,n,m;
    unordered_map<int, vector<int>> w;
    unordered_map<int, pq> cc;
    unordered_map<int, int> cnt;

    cin>>n;
    pt coords[n];

    fr(i,n){
        int x,y;
        cin>>x>>y;
        coords[i] = make_pair(x,y);
    }

    int wi[n];

    fr(i,n){
        int v;
        cin>>v;
        w[v].push_back(i+1);
        cnt[v]++;
        wi[i] = v;
    }

    fr(i,n){
        int d = coords[i].second - coords[i].first;
        if(cnt.find(d) != cnt.end()){
            cnt[d]--;
            cc[d].push(coords[i]);
        } else {
            cout<<"NO";
            return 0;
        }
    }

    stringstream res;

    res<<"YES\n";
    pt maxX = make_pair(0,0), maxY = make_pair(0,0);
    int val[2] = {0};
    fr(i,n){
        pt curr = cc[wi[i]].top();
        cc[wi[i]].pop();
        if(curr.first < maxX.first && curr.second < maxY.second){
            cout<<"NO";
            return 0;
        }

        if(curr.first >= maxX.first){
            maxX = curr;
            val[0] = i+1;
        }
        if(curr.second >= maxY.second){
            maxY = curr;
            val[1] = i+1;
        }

        res<<curr.first<<" "<<curr.second<<"\n";
    }
    cout<<res.str();
    return 0;

}


#include <iostream>
#include <unordered_map>
#include <queue>
#include <vector>
#include <sstream>
#define fr(i,n) for(i = 0;i<(n);++i)

using namespace std;
typedef pair<int,int> pt;

class Comp {
public:
    bool operator()(pt a, pt b){
        if(a.first < b.first)
            return false;
        else if(a.first == b.first){
            if(a.second < b.second){
                return false;
            }
        }
        return true;
    }
};

typedef priority_queue<pt,vector<pt>,Comp> pq;

int main(){
    int i,j,k,n,m;
    unordered_map<int, vector<int>> w;
    unordered_map<int, pq> cc;
    unordered_map<int, int> cnt;

    cin>>n;
    pt coords[n];

    fr(i,n){
        int x,y;
        cin>>x>>y;
        coords[i] = make_pair(x,y);
    }

    int wi[n];

    fr(i,n){
        int v;
        cin>>v;
        w[v].push_back(i+1);
        cnt[v]++;
        wi[i] = v;
    }

    fr(i,n){
        int d = coords[i].second - coords[i].first;
        if(cnt.find(d) != cnt.end()){
            cnt[d]--;
            cc[d].push(coords[i]);
        } else {
            cout<<"NO";
            return 0;
        }
    }

    stringstream res;

    res<<"YES\n";
    int maxX = 0, maxY = 0;
    int val = 0;
    fr(i,n){
        pt curr = cc[wi[i]].top();
        cc[wi[i]].pop();
        res<<curr.first<<" "<<curr.second<<"\n";
    }
    cout<<res.str();
    return 0;

}


#include <iostream>
#include <unordered_map>
#include <queue>
#include <vector>
#include <sstream>
#define fr(i,n) for(i = 0;i<(n);++i)

using namespace std;
typedef pair<int,int> pt;

class Comp {
public:
    bool operator()(pt a, pt b){
        if(a.first < b.first)
            return false;
        else if(a.first == b.first){
            if(a.second < b.second){
                return false;
            }
        }
        return true;
    }
};

typedef priority_queue<pt,vector<pt>,Comp> pq;

int main(){
    int i,j,k,n,m;
    unordered_map<int, vector<int>> w;
    unordered_map<int, pq> cc;
    unordered_map<int, int> cnt;

    cin>>n;
    pt coords[n];

    fr(i,n){
        int x,y;
        cin>>x>>y;
        coords[i] = make_pair(x,y);
    }

    int wi[n];

    fr(i,n){
        int v;
        cin>>v;
        w[v].push_back(i+1);
        cnt[v]++;
        wi[i] = v;
    }

    fr(i,n){
        int d = coords[i].second - coords[i].first;
        if(cnt.find(d) != cnt.end()){
            cnt[d]--;
            cc[d].push(coords[i]);
        } else {
            cout<<"NO";
            return 0;
        }
    }

    stringstream res;

    res<<"YES\n";
    pt maxX = make_pair(0,0), maxY = make_pair(0,0);
    int val[2] = {0};
    fr(i,n){
        pt curr = cc[wi[i]].top();
        cc[wi[i]].pop();
        if(curr.first > maxX.first){
            if(i+1 < val[0]){
                cout<<"NO";
                return 0;
            } else {
                val[0] = i+1;
                maxX = curr;
            }
        }

        if(curr.second > maxY.second){
            if(i+1 < val[1]){
                cout<<"NO";
                return 0;
            } else {
                val[1] = i+1;
                maxY = curr;
            }
        }

        res<<curr.first<<" "<<curr.second<<"\n";
    }
    cout<<res.str();
    return 0;

}


#include <iostream>
#include <unordered_map>
#include <queue>
#include <vector>
#include <sstream>
#define fr(i,n) for(i = 0;i<(n);++i)

using namespace std;
typedef pair<int,int> pt;

class Comp {
public:
    bool operator()(pt a, pt b){
        if(a.first < b.first)
            return false;
        else if(a.first == b.first){
            if(a.second < b.second){
                return false;
            }
        }
        return true;
    }
};

typedef priority_queue<pt,vector<pt>,Comp> pq;

int main(){
    int i,j,k,n,m;
    unordered_map<int, vector<int>> w;
    unordered_map<int, pq> cc;
    unordered_map<int, int> cnt;

    cin>>n;
    pt coords[n];

    fr(i,n){
        int x,y;
        cin>>x>>y;
        coords[i] = make_pair(x,y);
    }

    int wi[n];

    fr(i,n){
        int v;
        cin>>v;
        w[v].push_back(i+1);
        cnt[v]++;
        wi[i] = v;
    }

    fr(i,n){
        int d = coords[i].second - coords[i].first;
        if(cnt.find(d) != cnt.end()){
            cnt[d]--;
            cc[d].push(coords[i]);
        } else {
            cout<<"NO";
            return 0;
        }
    }

    stringstream res;

    res<<"YES\n";
    pt maxX = make_pair(0,0), maxY = make_pair(0,0);
    int val[2] = {0};
    fr(i,n){
        pt curr = cc[wi[i]].top();
        cc[wi[i]].pop();
        if(curr.first >= maxX.first){
            if(i+1 < val[0]){
                cout<<"NO";
                return 0;
            } else {
                val[0] = i+1;
                maxX = curr;
            }
        }

        if(curr.second >= maxY.second){
            if(i+1 < val[1]){
                cout<<"NO";
                return 0;
            } else {
                val[1] = i+1;
                maxY = curr;
            }
        }

        res<<curr.first<<" "<<curr.second<<"\n";
    }
    cout<<res.str();
    return 0;

}


#include <iostream>
#include <unordered_map>
#include <queue>
#include <vector>
#include <sstream>
#define fr(i,n) for(i = 0;i<(n);++i)

using namespace std;
typedef pair<int,int> pt;

class Comp {
public:
    bool operator()(pt a, pt b){
        if(a.first < b.first)
            return false;
        else if(a.first == b.first){
            if(a.second < b.second){
                return false;
            }
        }
        return true;
    }
};

typedef priority_queue<pt,vector<pt>,Comp> pq;

int main(){
    int i,j,k,n,m;
    unordered_map<int, vector<int>> w;
    unordered_map<int, pq> cc;
    unordered_map<int, int> cnt;

    cin>>n;
    pt coords[n];

    fr(i,n){
        int x,y;
        cin>>x>>y;
        coords[i] = make_pair(x,y);
    }

    int wi[n];

    fr(i,n){
        int v;
        cin>>v;
        w[v].push_back(i+1);
        cnt[v]++;
        wi[i] = v;
    }

    fr(i,n){
        int d = coords[i].second - coords[i].first;
        if(cnt.find(d) != cnt.end()){
            cnt[d]--;
            cc[d].push(coords[i]);
        } else {
            cout<<"NO";
            return 0;
        }
    }

    stringstream res;

    res<<"YES\n";
    int maxX = 0, maxY = 0;
    int val = 0;
    fr(i,n){
        pt curr = cc[wi[i]].top();
        cc[wi[i]].pop();
        if(curr.first > maxX || curr.second > maxY){
            if(i+1 < val){
                cout<<"NO";
                return 0;
            } else {
                val = i+1;
                maxX = curr.first;
                maxY = curr.second;
            }
        }
        res<<curr.first<<" "<<curr.second<<"\n";
    }
    cout<<res.str();
    return 0;

}


#include <bits/stdc++.h>

using namespace std;

const int N = 2e5;

int n, w[N], T[N * 4], cnt[N];

struct point
{
	int x, y;
} ans[N], a[N];

vector < int > g[N];

map < int, set < int > > st;

void upd(int pos, int v = 1, int tl = 0, int tr = 1e5 + 5)
{
	if (tl == tr)
	{
		T[v]++;
		return;
	}
	int tm = (tl + tr) / 2;
	if (pos <= tm) upd(pos, v * 2, tl, tm);
	else upd(pos, v * 2 + 1, tm + 1, tr);
	T[v] = T[v * 2] + T[v * 2 + 1];
}

int get(int l, int r, int v = 1, int tl = 0, int tr = 1e5 + 5)
{
	if (tl > r || tr < l) return 0;
	if (l <= tl && tr <= r) return T[v];
	int tm = (tl + tr) / 2;
	return get(l, r, v * 2, tl, tm) + get(l, r, v * 2 + 1, tm + 1, tr);
}

int main()
{
  scanf("%d", &n);
  for (int i = 1;i <= n;i++) scanf("%d%d", &a[i].x, &a[i].y), g[a[i].x].push_back(i);
  for (int i = 1;i <= n;i++) scanf("%d", &w[i]), st[w[i]].insert(i);
  for (int i = 0;i <= 1e5 + 5;i++)
  {
  	for (auto it : g[i]) upd(a[it].y);
  	for (auto it : g[i]) cnt[it] = get(0, a[it].y);
  }
  for (int i = 1;i <= n;i++)
	{
		int w = a[i].y - a[i].x;
		if (st[w].size() > 0 && *st[w].rbegin() >= cnt[i])
		{
			auto it = st[w].lower_bound(cnt[i]);
			ans[*it] = a[i];
			st[w].erase(it);
			continue;
		}
		puts("NO");
		return 0;
	}
	puts("YES");
  for (int i = 1;i <= n;i++) printf("%d %d\n", ans[i].x, ans[i].y);
	return 0;
}


#include <bits/stdc++.h>

using namespace std;

const int N = 1e6;

const int base = 2e5;

int n, w[N], T[N], cnt[N];

struct point
{
	int x, y;
} ans[N], a[N];

set < int > st[N];

vector < int > g[N];

void upd(int x)
{
	for (int i = x;i <= base;i = (i | (i + 1))) T[i]++;
}

int get(int x)
{
	int ans = 0;
	for (int i = x;i >= 0;i = (i & (i + 1)) - 1) ans += T[i];
	return ans;
}

int main()
{
  scanf("%d", &n);
  for (int i = 1;i <= n;i++) scanf("%d%d", &a[i].x, &a[i].y), g[a[i].x].push_back(i);
  for (int i = 1;i <= n;i++) scanf("%d", &w[i]), st[w[i] + base].insert(i);
  for (int i = 0;i <= base;i++)
  {
  	for (auto it : g[i]) upd(a[it].y);
  	for (auto it : g[i]) cnt[it] = get(a[it].y);
  }
  for (int i = 1;i <= n;i++)
	{
		int w = a[i].y - a[i].x + base;
		if (w < 0 || st[w].size() == 0 || *st[w].rbegin() < cnt[i])
		{
			puts("NO");
			return 0;
		}
		auto it = st[w].lower_bound(cnt[i]);
		st[w].erase(it);
		ans[*it] = a[i];
	}
	puts("YES");
  for (int i = 1;i <= n;i++) printf("%d %d\n", ans[i].x, ans[i].y);
	return 0;
}


#include <bits/stdc++.h>

using namespace std;

const int N = 5e5;

const int base = 2e5;

int n, w[N], T[N], cnt[N];

struct point
{
	int x, y;
} ans[N], a[N];

set < int > st[N];

vector < int > g[N];

void upd(int x)
{
	for (int i = x;i <= base;i = (i | (i + 1))) T[i]++;
}

int get(int x)
{
	int ans = 0;
	for (int i = x;i >= 0;i = (i & (i + 1)) - 1) ans += T[i];
	return ans;
}

int main()
{
  scanf("%d", &n);
  for (int i = 1;i <= n;i++) scanf("%d%d", &a[i].x, &a[i].y), g[a[i].x].push_back(i);
  for (int i = 1;i <= n;i++) scanf("%d", &w[i]), st[w[i] + base].insert(i);
  for (int i = 1;i <= base;i++)
  {
  	for (auto it : g[i]) upd(a[it].y);
  	for (auto it : g[i]) cnt[it] = get(a[it].y);
  }
  for (int i = 1;i <= n;i++)
	{
		int w = a[i].y - a[i].x + base;
		if (st[w].size() == 0 || *st[w].rbegin() < cnt[i])
		{
			puts("NO");
			return 0;
		}
		auto it = st[w].lower_bound(cnt[i]);
		st[w].erase(it);
		ans[*it] = a[i];
	}
	puts("YES");
  for (int i = 1;i <= n;i++) printf("%d %d\n", ans[i].x, ans[i].y);
	return 0;
}


#include <bits/stdc++.h>

using namespace std;

const int N = 2e5;

const int base = 1e5;

int n, w[N], T[N], cnt[N];

struct point
{
	int x, y;
} ans[N], a[N];

set < int > st[N + N];

vector < int > g[N];

void upd(int x)
{
	for (int i = x;i <= base;i = (i | (i + 1))) T[i]++;
}

int get(int x)
{
	int ans = 0;
	for (int i = x;i >= 0;i = (i & (i + 1)) - 1) ans += T[i];
	return ans;
}

int main()
{
  scanf("%d", &n);
  for (int i = 1;i <= n;i++) scanf("%d%d", &a[i].x, &a[i].y), g[a[i].x].push_back(i);
  for (int i = 1;i <= n;i++) scanf("%d", &w[i]), st[w[i] + base].insert(i);
  for (int i = 1;i <= base;i++)
  {
  	for (auto it : g[i]) upd(a[it].y);
  	for (auto it : g[i]) cnt[it] = get(a[it].y);
  }
  for (int i = 1;i <= n;i++)
	{
		int w = a[i].y - a[i].x + base;
		if (st[w].size() == 0 || *st[w].rbegin() < cnt[i])
		{
			puts("NO");
			return 0;
		}
		auto it = st[w].lower_bound(cnt[i]);
		st[w].erase(it);
		ans[*it] = a[i];
	}
	puts("YES");
  for (int i = 1;i <= n;i++) printf("%d %d\n", ans[i].x, ans[i].y);
	return 0;
}


#include <bits/stdc++.h>

using namespace std;

const int N = 2e6;

const int base = 4e5;

int n, w[N], T[N], cnt[N];

struct point
{
	int x, y;
} ans[N], a[N];

set < int > st[N];

vector < int > g[N];

void upd(int x)
{
	for (int i = x;i <= base;i = (i | (i + 1))) T[i]++;
}

int get(int x)
{
	int ans = 0;
	for (int i = x;i >= 0;i = (i & (i + 1)) - 1) ans += T[i];
	return ans;
}

int main()
{
  scanf("%d", &n);
  for (int i = 1;i <= n;i++) scanf("%d%d", &a[i].x, &a[i].y), g[a[i].x].push_back(i);
  for (int i = 1;i <= n;i++)
  {
  	scanf("%d", &w[i]);
  	if (w[i] + base < 0)
  	{
  		puts("NO");
  		return 0;
  	}
  	st[w[i] + base].insert(i);
  }
  for (int i = 0;i <= base;i++)
  {
  	for (auto it : g[i]) upd(a[it].y);
  	for (auto it : g[i]) cnt[it] = get(a[it].y);
  }
  for (int i = 1;i <= n;i++)
	{
		int w = a[i].y - a[i].x + base;
		if (w >= 0 && st[w].size() > 0 && *st[w].rbegin() >= cnt[i])
		{
			auto it = st[w].lower_bound(cnt[i]);
			st[w].erase(it);
			ans[*it] = a[i];
			continue;
		}
		puts("NO");
		return 0;
	}
	puts("YES");
  for (int i = 1;i <= n;i++) printf("%d %d\n", ans[i].x, ans[i].y);
	return 0;
}


#include <bits/stdc++.h>

using namespace std;

const int N = 1e6;

const int base = 1e5 + 5;

int n, w[N], T[N * 3], cnt[N];

struct point
{
	int x, y;
} ans[N], a[N];

set < int > st[N];

vector < int > g[N];

void upd(int pos, int v = 1, int tl = 0, int tr = base)
{
	if (tl == tr)
	{
		T[v]++;
		return;
	}
	int tm = (tl + tr) / 2;
	if (pos <= tm) upd(pos, v * 2, tl, tm);
	else upd(pos, v * 2 + 1, tm + 1, tr);
	T[v] = T[v * 2] + T[v * 2 + 1];
}

int get(int l, int r, int v = 1, int tl = 0, int tr = base)
{
	if (tl > r || tr < l) return 0;
	if (l <= tl && tr <= r) return T[v];
	int tm = (tl + tr) / 2;
	return get(l, r, v * 2, tl, tm) + get(l, r, v * 2 + 1, tm + 1, tr);
}

int main()
{
  scanf("%d", &n);
  for (int i = 1;i <= n;i++) scanf("%d%d", &a[i].x, &a[i].y), g[a[i].x].push_back(i);
  for (int i = 1;i <= n;i++) scanf("%d", &w[i]), st[w[i] + base].insert(i);
  for (int i = 0;i <= base;i++)
  {
  	for (auto it : g[i]) upd(a[it].y);
  	for (auto it : g[i]) cnt[it] = get(0, a[it].y);
  }
  for (int i = 1;i <= n;i++)
	{
		int w = a[i].y - a[i].x + base;
		if (w >= 0 && st[w].size() > 0 && *st[w].rbegin() >= cnt[i])
		{
			auto it = st[w].lower_bound(cnt[i]);
			st[w].erase(it);
			ans[*it] = a[i];
			continue;
		}
		puts("NO");
		return 0;
	}
	puts("YES");
  for (int i = 1;i <= n;i++) printf("%d %d\n", ans[i].x, ans[i].y);
	return 0;
}


#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <iostream>
#include <string>
#include <vector>
#include <deque>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <algorithm>
#include <functional>
using namespace std;
const int maxn = 100010;

struct Node {
    int x, y;
    Node() { }
    Node(int _x, int _y) : x(_x), y(_y) { }
    bool operator < (const Node &p) const {
        return x < p.x;
    }
};

struct Node2 {
    int x, y;
    Node2() { }
    Node2(int _x, int _y) : x(_x), y(_y) { }
    bool operator < (const Node2 &p) const {
        return x <= p.x && y <= p.y;
    }
};

vector<Node> vec[2*maxn];
vector<Node> res;
set<Node2> mySet;
int index[2*maxn];
int w[maxn];

int main() {

    //freopen("aa.in", "r", stdin);
    Node2 tmp;
    int n, x, y;
    bool ok = true;
    scanf("%d", &n);
    memset(index, 0, sizeof(index));
    for(int i = 0; i < n; ++i) {
        scanf("%d %d", &x, &y);
        vec[y-x+100000].push_back(Node(x, y));
    }
    for(int i = 0; i <= 200000; ++i) {
        sort(vec[i].begin(), vec[i].end());
    }
    for(int i = 0; i < n; ++i) {
        scanf("%d", &w[i]);
        if(!ok) continue;
        w[i] += 100000;

        if(index[w[i]] < (int)vec[w[i]].size()) {
            x = vec[w[i]][index[w[i]]].x;
            y = vec[w[i]][index[w[i]]].y;
            res.push_back(Node(x, y));
            tmp.x = x;
            tmp.y = y;
            //res.push_back(Node(vec[w[i]][index[w[i]]].x, vec[w[i]][index[w[i]]].y));
            if(mySet.upper_bound(tmp) != mySet.end()) {
                ok = false;
            } else {
                mySet.insert(tmp);
            }
            index[w[i]]++;
        } else {
            ok = false;
        }
    }
    if(!ok) {
        printf("NO\n");
    } else {

        if(!ok) {
            printf("NO\n");
        } else {
            printf("YES\n");
            for(int i = 0; i < n; ++i) {
                printf("%d %d\n", res[i].x, res[i].y);
            }
        }
    }
    return 0;
}


#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <iostream>
#include <string>
#include <vector>
#include <deque>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <algorithm>
#include <functional>
using namespace std;
const int maxn = 100010;

struct Node {
    int x, y;
    Node() { }
    Node(int _x, int _y) : x(_x), y(_y) { }
    bool operator < (const Node &p) const {
        return x < p.x;
    }
};

struct Node2 {
    int x, y;
    Node2() { }
    Node2(int _x, int _y) : x(_x), y(_y) { }
    bool operator < (const Node2 &p) const {
        return x <= p.x && y <= p.y;
    }
};

vector<Node> vec[2*maxn];
vector<Node2> res;
set<Node2> mySet;
int index[2*maxn];
int w[maxn];

int main() {

    //freopen("aa.in", "r", stdin);

    Node2 tmp;
    int n, x, y;
    bool ok = true;
    scanf("%d", &n);
    memset(index, 0, sizeof(index));
    for(int i = 0; i < n; ++i) {
        scanf("%d %d", &x, &y);
        vec[y-x+100000].push_back(Node(x, y));
    }
    for(int i = 0; i <= 200000; ++i) {
        sort(vec[i].begin(), vec[i].end());
    }
    for(int i = 0; i < n; ++i) {
        scanf("%d", &w[i]);
        if(!ok) continue;
        w[i] += 100000;
        if(index[w[i]] < (int)vec[w[i]].size()) {
            x = vec[w[i]][index[w[i]]].x;
            y = vec[w[i]][index[w[i]]].y;
            //res.push_back(Node(x, y));
            tmp.x = x;
            tmp.y = y;
            res.push_back(tmp);
            /*
            if(mySet.upper_bound(tmp) != mySet.end()) {
                ok = false;
            } else {
                mySet.insert(tmp);
            }
            */
            index[w[i]]++;
        } else {
            ok = false;
        }
    }
    if(!ok) {
        printf("NO\n");
    } else {
        stable_sort(res.begin(), res.end());
        for(int i = 0; i < n; ++i) {
            if(res[i].y - res[i].x + 100000 != w[i]) {
                ok = false;
            }
        }
        if(!ok) {
            printf("NO\n");
        } else {
            printf("YES\n");
            for(int i = 0; i < n; ++i) {
                printf("%d %d\n", res[i].x, res[i].y);
            }
        }
    }
    return 0;
}


#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <iostream>
#include <string>
#include <vector>
#include <deque>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <algorithm>
#include <functional>
using namespace std;
const int maxn = 100010;

struct Node {
    int x, y;
    Node() { }
    Node(int _x, int _y) : x(_x), y(_y) { }
    bool operator < (const Node &p) const {
        if(x <= p.x && y <= p.y) {
            return true;
        } else {
            return x < p.x;
        }
    }
};

struct Node2 {
    int x, y;
    Node2() { }
    Node2(int _x, int _y) : x(_x), y(_y) { }
    bool operator < (const Node2 &p) const {
        return x <= p.x && y <= p.y;
    }
};
vector<Node> vec[2*maxn];
vector<Node2> res;
int index[2*maxn];
int w[maxn];

int main() {

    //freopen("aa.in", "r", stdin);

    int n, x, y;
    bool ok = true;
    scanf("%d", &n);
    memset(index, 0, sizeof(index));
    for(int i = 0; i < n; ++i) {
        scanf("%d %d", &x, &y);
        vec[y-x+100000].push_back(Node(x, y));
    }
    for(int i = 1; i <= 200000; ++i) {
        sort(vec[i].begin(), vec[i].end());
    }
    for(int i = 0; i < n; ++i) {
        scanf("%d", &w[i]);
        w[i] += 100000;
        if(index[w[i]] < (int)vec[w[i]].size()) {
            res.push_back(Node2(vec[w[i]][index[w[i]]].x, vec[w[i]][index[w[i]]].y));
            index[w[i]]++;
        } else {
            ok = false;
        }
    }
    if(!ok) {
        printf("NO\n");
    } else {
        sort(res.begin(), res.end());
        for(int i = 0; i < n; ++i) {
            if(res[i].y - res[i].x + 100000 != w[i]) {
                ok = false;
                break;
            }
        }
        if(!ok) {
            printf("NO\n");
        } else {
            printf("YES\n");
            for(int i = 0; i < n; ++i) {
                printf("%d %d\n", res[i].x, res[i].y);
            }
        }
    }
    return 0;
}


#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <iostream>
#include <string>
#include <vector>
#include <deque>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <algorithm>
#include <functional>
using namespace std;
const int maxn = 100010;

struct Node {
    int x, y;
    Node() { }
    Node(int _x, int _y) : x(_x), y(_y) { }
    bool operator < (const Node &p) const {
        return x <= p.x && y <= p.y;
    }
};

vector<Node> vec[2*maxn];
vector<Node> res;
int index[2*maxn];
int w[maxn];

int main() {

    //freopen("aa.in", "r", stdin);

    int n, x, y;
    bool ok = true;
    scanf("%d", &n);
    memset(index, 0, sizeof(index));
    for(int i = 0; i < n; ++i) {
        scanf("%d %d", &x, &y);
        vec[y-x+100000].push_back(Node(x, y));
    }
    for(int i = 1; i <= 200000; ++i) {
        sort(vec[i].begin(), vec[i].end());
    }
    for(int i = 0; i < n; ++i) {
        scanf("%d", &w[i]);
        w[i] += 100000;
        if(index[w[i]] < (int)vec[w[i]].size()) {
            res.push_back(Node(vec[w[i]][index[w[i]]].x, vec[w[i]][index[w[i]]].y));
            index[w[i]]++;
        } else {
            ok = false;
        }
    }
    if(!ok) {
        printf("NO\n");
    } else {
        sort(res.begin(), res.end());
        for(int i = 0; i < n; ++i) {
            if(res[i].y - res[i].x + 100000 != w[i]) {
                ok = false;
                break;
            }
        }
        if(!ok) {
            printf("NO\n");
        } else {
            printf("YES\n");
            for(int i = 0; i < n; ++i) {
                printf("%d %d\n", res[i].x, res[i].y);
            }
        }
    }
    return 0;
}


#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <iostream>
#include <string>
#include <vector>
#include <deque>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <algorithm>
#include <functional>
using namespace std;
const int maxn = 100010;

struct Node {
    int x, y;
    Node() { }
    Node(int _x, int _y) : x(_x), y(_y) { }
    bool operator < (const Node &p) const {
        return x < p.x;
    }
};

struct Node2 {
    int x, y;
    Node2() { }
    Node2(int _x, int _y) : x(_x), y(_y) {}
    bool operator < (const Node2 &p) const {
        return x <= p.x && y <= p.y;
    }
};

vector<Node> vec[2*maxn];
vector<Node2> res;
int index[2*maxn];
int w[maxn];

int main() {

    //freopen("aa.in", "r", stdin);

    int n, x, y;
    bool ok = true;
    scanf("%d", &n);
    memset(index, 0, sizeof(index));
    for(int i = 0; i < n; ++i) {
        scanf("%d %d", &x, &y);
        vec[y-x+100000].push_back(Node(x, y));
    }
    for(int i = 0; i <= 200000; ++i) {
        sort(vec[i].begin(), vec[i].end());
    }
    for(int i = 0; i < n; ++i) {
        scanf("%d", &w[i]);
        w[i] += 100000;
        if(index[w[i]] < (int)vec[w[i]].size()) {
            res.push_back(Node2(vec[w[i]][index[w[i]]].x, vec[w[i]][index[w[i]]].y));
            index[w[i]]++;
        } else {
            ok = false;
        }
    }
    if(!ok) {
        printf("NO\n");
    } else {
        sort(res.begin(), res.end());
        for(int i = 0; i < n; ++i) {
            if(res[i].y - res[i].x + 100000 != w[i]) {
                ok = false;
                break;
            }
        }
        if(!ok) {
            printf("NO\n");
        } else {
            printf("YES\n");
            for(int i = 0; i < n; ++i) {
                printf("%d %d\n", res[i].x, res[i].y);
            }
        }
    }
    return 0;
}


#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <iostream>
#include <string>
#include <vector>
#include <deque>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <algorithm>
#include <functional>
using namespace std;
const int maxn = 100010;

struct Node {
    int x, y;
    Node() { }
    Node(int _x, int _y) : x(_x), y(_y) { }
    bool operator < (const Node &p) const {
        return x < p.x;
    }
};

struct Node2 {
    int x, y;
    Node2() { }
    Node2(int _x, int _y) : x(_x), y(_y) {}
    bool operator < (const Node2 &p) const {
        return x <= p.x && y <= p.y;
    }
};

vector<Node> vec[2*maxn];
vector<Node2> res;
int index[2*maxn];
int w[maxn];

int main() {

    //freopen("aa.in", "r", stdin);

    int n, x, y;
    bool ok = true;
    scanf("%d", &n);
    memset(index, 0, sizeof(index));
    for(int i = 0; i < n; ++i) {
        scanf("%d %d", &x, &y);
        vec[y-x+100000].push_back(Node(x, y));
    }
    for(int i = 1; i <= 200000; ++i) {
        sort(vec[i].begin(), vec[i].end());
    }
    for(int i = 0; i < n; ++i) {
        scanf("%d", &w[i]);
        w[i] += 100000;
        if(index[w[i]] < (int)vec[w[i]].size()) {
            res.push_back(Node2(vec[w[i]][index[w[i]]].x, vec[w[i]][index[w[i]]].y));
            index[w[i]]++;
        } else {
            ok = false;
        }
    }
    if(!ok) {
        printf("NO\n");
    } else {
        sort(res.begin(), res.end());
        for(int i = 0; i < n; ++i) {
            if(res[i].y - res[i].x + 100000 != w[i]) {
                ok = false;
                break;
            }
        }
        if(!ok) {
            printf("NO\n");
        } else {
            printf("YES\n");
            for(int i = 0; i < n; ++i) {
                printf("%d %d\n", res[i].x, res[i].y);
            }
        }
    }
    return 0;
}


#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <iostream>
#include <string>
#include <vector>
#include <deque>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <algorithm>
#include <functional>
using namespace std;
const int maxn = 100010;

struct Node {
    int x, y;
    Node() { }
    Node(int _x, int _y) : x(_x), y(_y) { }
    bool operator < (const Node &p) const {
        /*
        if(x <= p.x && y <= p.y) {
            return true;
        } else {
            return x < p.x;
        }
        */
        return x <= p.x && y <= p.y;
    }
};
vector<Node> vec[2*maxn], res;
int index[2*maxn];
int w[maxn];

int main() {

    //freopen("aa.in", "r", stdin);

    int n, x, y;
    bool ok = true;
    scanf("%d", &n);
    memset(index, 0, sizeof(index));
    for(int i = 0; i < n; ++i) {
        scanf("%d %d", &x, &y);
        vec[y-x+100000].push_back(Node(x, y));
    }
    for(int i = 1; i <= 200000; ++i) {
        sort(vec[i].begin(), vec[i].end());
    }
    for(int i = 0; i < n; ++i) {
        scanf("%d", &w[i]);
        w[i] += 100000;
        if(index[w[i]] < (int)vec[w[i]].size()) {
            res.push_back(vec[w[i]][index[w[i]]]);
            index[w[i]]++;
        } else {
            ok = false;
        }
    }
    if(!ok) {
        printf("NO\n");
    } else {
        sort(res.begin(), res.end());
        for(int i = 0; i < n; ++i) {
            if(res[i].y - res[i].x + 100000 != w[i]) {
                ok = false;
                break;
            }
        }
        if(!ok) {
            printf("NO\n");
        } else {
            printf("YES\n");
            for(int i = 0; i < n; ++i) {
                printf("%d %d\n", res[i].x, res[i].y);
            }
        }
    }
    return 0;
}


/*#include <bits/stdc++.h>
using namespace std;
#define forr(n) for (int i=0;i<n;i++)
#define forx(x,n) for(int i=x;i<n;i++)
#define len(x,s) int x=s.length()
#define lenv(s) s.length()
#define pb push_back
#define endd(x) return x;
#define mems(a,v) memset(a,v,sizeof a)
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(),v.rend()
#define sfi(x) scanf("%d",&x)
#define sfi2(x,y) scanf("%i%i",&x,&y)
#define sfu(x) scanf("%hd",&x)
#define sfu2(x,y) scanf("%hd%hd",&x,&y)
#define mp(x,y) make_pair(x,y)
//#define nll cout<<endl;
#define nl cout<<endl
typedef long long ll;
typedef unsigned long long ull;
typedef unsigned int ui;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef pair<int, int> ii;
typedef vector<ii> vii;
typedef set<int> si;
typedef map<string, int> msi;
//int x[]={-1,0,1,-1,1,-1,0,1},y[]={-1,-1,-1,0,0,1,1,1};
#define MAX 1000000007
#define MOD 1000000007
#define oo 1e9
string ans[]={"NO\n","YES\n"};
void printv(vector<int> v){forr(v.size())cout<<v[i]<<" ";cout<<endl;}
ull summ(ull n){return ((n*n)+n)/2;}
bool isubseq(string s,string s1){len(ln,s1);len(lll,s);int i=0,j=0;for(;i<ln&&j<lll;i++)j+=(s1[i]==s[j]);return j==lll;}
string to_string(int val){if(!val)return "0";string s;while(val){s+=val%10+48;val/=10;}reverse(s.begin(),s.end());return s;}
bool incirc(double x,double y, double center_x,double center_y,double r){return(x-center_x)*(x-center_x)+(y-center_y)*(y-center_y)<=r*r;}
/// Actual solution starts here /////////////////////////////////////////////////////////////
int main()
{
    ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
    #ifndef ONLINE_JUDGE
        //freopen("A2.out","w",stdout);
        freopen("a1.in","r",stdin);
    #endif
    int n;
    while(cin>>n)
    {
        int arr[n];
        bool fl=1;
        forr(n)
        {
            cin>>arr[i];
        }
        forr(n)
        {
            for(int j=0;j<n;j++)
            {
                for(int k=j+1;k<n;k++)
                {
                    if(arr[i]== arr[j]+ arr[k])
                        {cout<<i+1<< " "<<j+1<<" "<<k+1<<"\n";fl=0;}
                }
            }
        }
        if(fl )
            cout<<"-1"<<endl;
        //cout<<minn<<"\n";
    }
    return 0;
}*/
    #include <iostream>
#include <stdio.h>
#include <algorithm>
#include <math.h>
#include <vector>
#include <cstring>
#include <string>
#include <queue>
#include <map>
#include <set>
#include <stdlib.h>
#include <ctime>
using namespace std;
#define forr(n) for(long long i=0;i<n;i++)
#define forrr(n) for(long long i=1;i<=n;i++)
#define forb(n) for(long long i=n;i>=0;i--)
typedef long long   ll;
typedef long double ld;

//vector<int> xi;

set<char> s2;
set<char> s3;
queue<ll> myqueue;
vector<ll> wi;
vector< vector<ll> > nums;
vector<ll> numbers;
vector<int> numbers4;

vector<string> V1;
vector<string> V2;
vector<int> set3;
vector<int> wrong;
vector< pair<ll, ll > > points;
vector< pair<ll, ll > > result;
//V.push_back(make_pair(temp1,temp2));
//scanf("%ld %ld\n", &data[p].first, &data[p].second);
vector< pair<int, string > > ypairV;
pair<int,int> ypair;

int main()
{
   //ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
    #ifndef ONLINE_JUDGE
    freopen("a1.in","r", stdin);
    //freopen("out.txt","w", stdout);
    #endif
    ll n,l=0,t=0,y=0,r=0,k=0,i=0,pos1=0,pointer=1,pos2=0,j=0,sum1=0,row=0,col=0,counter=0,temp,flag2=0,flag1=0,sum=0;
    cin>>n;
    forr(n)
    {
        cin>>temp>>flag1;
        points.push_back(make_pair(temp,flag1));
    }

    forr(n)
    {
        cin>>temp;
        wi.push_back(temp);
    }

    forr(wi.size())
    {
        temp = i;
        forr(points.size())
        {
            if((points[i].second - points[i].first)== wi[temp])
            {
                result.push_back(make_pair(points[i].first,points[i].second));
                points.erase(points.begin()+i);
                break;
            }
        }
    }
     if(result.size()<n)
        {
            cout<<"NO"<<endl;
            return 0;
        }
        for (int i=0;i<n-1;i++)
        {
            if(result[i].first >= result[i+1].first && result[i].second >= result[i+1].second)
            {
                cout<<"a7a"<<endl;
                cout<<"NO"<<endl;
                break;
            }
        }

    cout<<"YES"<<endl;
    forr(result.size())
        cout<<result[i].first<<" "<<result[i].second<<endl;

    return 0;
}


/*#include <bits/stdc++.h>
using namespace std;
#define forr(n) for (int i=0;i<n;i++)
#define forx(x,n) for(int i=x;i<n;i++)
#define len(x,s) int x=s.length()
#define lenv(s) s.length()
#define pb push_back
#define endd(x) return x;
#define mems(a,v) memset(a,v,sizeof a)
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(),v.rend()
#define sfi(x) scanf("%d",&x)
#define sfi2(x,y) scanf("%i%i",&x,&y)
#define sfu(x) scanf("%hd",&x)
#define sfu2(x,y) scanf("%hd%hd",&x,&y)
#define mp(x,y) make_pair(x,y)
//#define nll cout<<endl;
#define nl cout<<endl
typedef long long ll;
typedef unsigned long long ull;
typedef unsigned int ui;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef pair<int, int> ii;
typedef vector<ii> vii;
typedef set<int> si;
typedef map<string, int> msi;
//int x[]={-1,0,1,-1,1,-1,0,1},y[]={-1,-1,-1,0,0,1,1,1};
#define MAX 1000000007
#define MOD 1000000007
#define oo 1e9
string ans[]={"NO\n","YES\n"};
void printv(vector<int> v){forr(v.size())cout<<v[i]<<" ";cout<<endl;}
ull summ(ull n){return ((n*n)+n)/2;}
bool isubseq(string s,string s1){len(ln,s1);len(lll,s);int i=0,j=0;for(;i<ln&&j<lll;i++)j+=(s1[i]==s[j]);return j==lll;}
string to_string(int val){if(!val)return "0";string s;while(val){s+=val%10+48;val/=10;}reverse(s.begin(),s.end());return s;}
bool incirc(double x,double y, double center_x,double center_y,double r){return(x-center_x)*(x-center_x)+(y-center_y)*(y-center_y)<=r*r;}
/// Actual solution starts here /////////////////////////////////////////////////////////////
int main()
{
    ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
    #ifndef ONLINE_JUDGE
        //freopen("A2.out","w",stdout);
        freopen("a1.in","r",stdin);
    #endif
    int n;
    while(cin>>n)
    {
        int arr[n];
        bool fl=1;
        forr(n)
        {
            cin>>arr[i];
        }
        forr(n)
        {
            for(int j=0;j<n;j++)
            {
                for(int k=j+1;k<n;k++)
                {
                    if(arr[i]== arr[j]+ arr[k])
                        {cout<<i+1<< " "<<j+1<<" "<<k+1<<"\n";fl=0;}
                }
            }
        }
        if(fl )
            cout<<"-1"<<endl;
        //cout<<minn<<"\n";
    }
    return 0;
}*/
    #include <iostream>
#include <stdio.h>
#include <algorithm>
#include <math.h>
#include <vector>
#include <cstring>
#include <string>
#include <queue>
#include <map>
#include <set>
#include <stdlib.h>
#include <ctime>
using namespace std;
#define forr(n) for(long long i=0;i<n;i++)
#define forrr(n) for(long long i=1;i<=n;i++)
#define forb(n) for(long long i=n;i>=0;i--)
typedef long long   ll;
typedef long double ld;

//vector<int> xi;

set<char> s2;
set<char> s3;
queue<ll> myqueue;
vector<ll> wi;
vector< vector<ll> > nums;
vector<ll> numbers;
vector<int> numbers4;

vector<string> V1;
vector<string> V2;
vector<int> set3;
vector<int> wrong;
vector< pair<ll, ll > > points;
vector< pair<ll, ll > > result;
//V.push_back(make_pair(temp1,temp2));
//scanf("%ld %ld\n", &data[p].first, &data[p].second);
vector< pair<int, string > > ypairV;
pair<int,int> ypair;

int main()
{
   //ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
    #ifndef ONLINE_JUDGE
    freopen("a1.in","r", stdin);
    //freopen("out.txt","w", stdout);
    #endif
    ll n,l=0,t=0,y=0,r=0,k=0,i=0,pos1=0,pointer=1,pos2=0,j=0,sum1=0,row=0,col=0,counter=0,temp,flag2=0,flag1=0,sum=0;
    cin>>n;
    forr(n)
    {
        cin>>temp>>flag1;
        points.push_back(make_pair(temp,flag1));
    }

    forr(n)
    {
        cin>>temp;
        wi.push_back(temp);
    }

    forr(wi.size())
    {
        temp = i;
        forr(points.size())
        {
            if((points[i].second - points[i].first)== wi[temp])
            {
                result.push_back(make_pair(points[i].first,points[i].second));
                points.erase(points.begin()+i);
                break;
            }
        }
    }
     if(result.size()<n)
        {
            cout<<"NO"<<endl;
            return 0;
        }
        for (int i=0;i<n-1;i++)
        {
            if(result[i].first >= result[i+1].first && result[i].second >= result[i+1].second)
            {
                //cout<<"a7a"<<endl;
                cout<<"NO"<<endl;
                return 0;
            }
        }

    cout<<"YES"<<endl;
    forr(result.size())
        cout<<result[i].first<<" "<<result[i].second<<endl;

    return 0;
}


#include <bits/stdc++.h>
using namespace std;
#define forr(n) for (int i=0;i<n;i++)
#define forx(x,n) for(int i=x;i<n;i++)
#define len(x,s) int x=s.length()
#define lenv(s) s.length()
#define pb push_back
#define endd(x) return x;
#define mems(a,v) memset(a,v,sizeof a)
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(),v.rend()
#define sfi(x) scanf("%d",&x)
#define sfi2(x,y) scanf("%i%i",&x,&y)
#define sfu(x) scanf("%hd",&x)
#define sfu2(x,y) scanf("%hd%hd",&x,&y)
#define mp(x,y) make_pair(x,y)
#define V vector
//#define nll cout<<endl;
#define nl cout<<endl
typedef long long ll;
typedef unsigned long long ull;
typedef unsigned int ui;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef pair<int, int> ii;
typedef vector<ii> vii;
typedef set<int> si;
typedef map<string, int> msi;
//int x[]={-1,0,1,-1,1,-1,0,1},y[]={-1,-1,-1,0,0,1,1,1};
#define MAX 1000000007/////
#define MOD 1000000007
#define oo 1e9
//string ans[]={"NO\n","YES\n"};
void printv(vector<int> v){forr(v.size())cout<<v[i]<<" ";cout<<endl;}
ull summ(ull n){return ((n*n)+n)/2;}
bool isubseq(string s,string s1){len(ln,s1);len(lll,s);int i=0,j=0;for(;i<ln&&j<lll;i++)j+=(s1[i]==s[j]);return j==lll;}
string to_string(int val){if(!val)return "0";string s;while(val){s+=val%10+48;val/=10;}reverse(s.begin(),s.end());return s;}
bool incirc(double x,double y, double center_x,double center_y,double r){return(x-center_x)*(x-center_x)+(y-center_y)*(y-center_y)<=r*r;}
ull gcd (ull a,ull b){ull c;while(a!=0){c=a;a=b%a;b=c;}return b;}
///Actual solution starts here/////////////////////Sherbi7y////////////////////////////////////////
int main()
{
    ios_base::sync_with_stdio(0);cin.tie(0);//cout.tie(0);
    #ifndef ONLINE_JUDGE
        //freopen("A2.out","w",stdout);
        freopen("a1.in","r",stdin);
    #endif
    int n;
    bool fl=0;
    while(cin>>n)
    {
        int xa[n],ya[n];
        int xx,yy,mm,w;
        ii o;
        map<int, set<ii> > pintx;
        forr(n)
        {
            cin>>xx>>yy;
            mm=yy-xx;
            pintx[mm].insert({xx,yy});
        }
        forr(n)
        {
            cin>>w;
            if (pintx[w].empty())
                {
                    fl=1;
                }
            o=*pintx[w].begin();
            xa[i] = o.first;
            ya[i] = o.second;
            pintx[w].erase(o);
        }
        for (int i=0;i<n-1;i++)
        {
            if(xa[i]>= xa[i+1]&& ya[i]>= ya[i+1])
            {
                fl=1;
                break;
            }
        }
        if(fl )
        {
            cout<<"NO\n";
            continue;
        }
        cout<<"YES\n";
        forr(n)
        {
            cout<<xa[i]<<" "<<ya[i]<<"\n";
        }
    }
    return 0;
}
/**/


#include <bits/stdc++.h>
using namespace std;
#define forr(n) for (int i=0;i<n;i++)
#define forx(x,n) for(int i=x;i<n;i++)
#define len(x,s) int x=s.length()
#define lenv(s) s.length()
#define pb push_back
#define endd(x) return x;
#define mems(a,v) memset(a,v,sizeof a)
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(),v.rend()
#define sfi(x) scanf("%d",&x)
#define sfi2(x,y) scanf("%i%i",&x,&y)
#define sfu(x) scanf("%hd",&x)
#define sfu2(x,y) scanf("%hd%hd",&x,&y)
#define mp(x,y) make_pair(x,y)
#define V vector
//#define nll cout<<endl;
#define nl cout<<endl
typedef long long ll;
typedef unsigned long long ull;
typedef unsigned int ui;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef pair<int, int> ii;
typedef vector<ii> vii;
typedef set<int> si;
typedef map<string, int> msi;
//int x[]={-1,0,1,-1,1,-1,0,1},y[]={-1,-1,-1,0,0,1,1,1};
#define MAX 1000000007
#define MOD 1000000007
#define oo 1e9
//string ans[]={"NO\n","YES\n"};
void printv(vector<int> v){forr(v.size())cout<<v[i]<<" ";cout<<endl;}
ull summ(ull n){return ((n*n)+n)/2;}
bool isubseq(string s,string s1){len(ln,s1);len(lll,s);int i=0,j=0;for(;i<ln&&j<lll;i++)j+=(s1[i]==s[j]);return j==lll;}
string to_string(int val){if(!val)return "0";string s;while(val){s+=val%10+48;val/=10;}reverse(s.begin(),s.end());return s;}
bool incirc(double x,double y, double center_x,double center_y,double r){return(x-center_x)*(x-center_x)+(y-center_y)*(y-center_y)<=r*r;}
ull gcd (ull a,ull b){ull c;while(a!=0){c=a;a=b%a;b=c;}return b;}
///Actual solution starts here/////////////////////Sherbi7y////////////////////////////////////////
int main()
{
    ios_base::sync_with_stdio(0);cin.tie(0);//cout.tie(0);
    #ifndef ONLINE_JUDGE
        //freopen("A2.out","w",stdout);
        freopen("a1.in","r",stdin);
    #endif
    int n;
    bool fl=0;
    while(cin>>n)
    {
        int xa[n],ya[n];
        int xx,yy,mm,w;
        ii o;
        map<int, set<ii> > pintx;
        forr(n)
        {
            cin>>xx>>yy;
            mm=yy-xx;
            pintx[mm].insert({xx,yy});
        }
        forr(n)
        {
            cin>>w;
            if (pintx[w].empty())
                {
                    fl=1;
                }
            o=*pintx[w].begin();
            xa[i] = o.first;
            ya[i] = o.second;
            pintx[w].erase(o);
        }
        for (int i=0;i<n-1;i++)
        {
            if(xa[i]>= xa[i+1]&& ya[i]>= ya[i+1])
            {
                fl=1;
                break;
            }
        }
        if(fl )
        {
            cout<<"NO\n";
            continue;
        }
        cout<<"YES\n";
        forr(n)
        {
            cout<<xa[i]<<" "<<ya[i]<<"\n";
        }
    }
    return 0;
}
/**/


#include <bits/stdc++.h>
using namespace std;
#define forr(n) for (int i=0;i<n;i++)
#define forx(x,n) for(int i=x;i<n;i++)
#define len(x,s) int x=s.length()
#define lenv(s) s.length()
#define pb push_back
#define endd(x) return x;
#define mems(a,v) memset(a,v,sizeof a)
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(),v.rend()
#define sfi(x) scanf("%d",&x)
#define sfi2(x,y) scanf("%i%i",&x,&y)
#define sfu(x) scanf("%hd",&x)
#define sfu2(x,y) scanf("%hd%hd",&x,&y)
#define mp(x,y) make_pair(x,y)
#define V vector
//#define nll cout<<endl;
#define nl cout<<endl
typedef long long ll;
typedef unsigned long long ull;
typedef unsigned int ui;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef pair<int, int> ii;
typedef vector<ii> vii;
typedef set<int> si;
typedef map<string, int> msi;
//int x[]={-1,0,1,-1,1,-1,0,1},y[]={-1,-1,-1,0,0,1,1,1};
#define MAX 1000000007
#define MOD 1000000007
#define oo 1e9
//string ans[]={"NO\n","YES\n"};
void printv(vector<int> v){forr(v.size())cout<<v[i]<<" ";cout<<endl;}
ull summ(ull n){return ((n*n)+n)/2;}
bool isubseq(string s,string s1){len(ln,s1);len(lll,s);int i=0,j=0;for(;i<ln&&j<lll;i++)j+=(s1[i]==s[j]);return j==lll;}
string to_string(int val){if(!val)return "0";string s;while(val){s+=val%10+48;val/=10;}reverse(s.begin(),s.end());return s;}
bool incirc(double x,double y, double center_x,double center_y,double r){return(x-center_x)*(x-center_x)+(y-center_y)*(y-center_y)<=r*r;}
ull gcd (ull a,ull b){ull c;while(a!=0){c=a;a=b%a;b=c;}return b;}
///Actual solution starts here/////////////////////Sherbi7y////////////////////////////////////////
ii lesser(int oi,int oj, int ti,int tj)
{
	if(oi <= ti && oj <= tj)
		return {oi,oj};
	if((oi >= ti && oj >= tj))
		return {ti, tj};
	if(oi < ti)
		return {oi,oj};
	return {ti, tj};
}
int main()
{
    ios_base::sync_with_stdio(0);cin.tie(0);//cout.tie(0);
    #ifndef ONLINE_JUDGE
        //freopen("A2.out","w",stdout);
        freopen("a1.in","r",stdin);
    #endif
   	int n;
   	bool fl=0;
   	while(cin>>n)
   	{
   		int xa[n],ya[n];
   		int xx,yy,mm,w;
   		ii o,t;
   		V< set<ii> > pintx(200010);
   		forr(n)
   		{
   			cin>>xx>>yy;
   			mm=yy-xx;
   			pintx[mm+100000].insert({xx,yy});
   		}
   		forr(n)
   		{
   			//cout<<"f"<<endl;
   			cin>>w;
   			//cout<<w<<endl;
   			w+=100000;
   			if (pintx[w].empty())
   				{fl=1;}
   			o=*pintx[w].begin();
   			xa[i] = o.first;
   			ya[i] = o.second;
   			pintx[w].erase(o);
   			/*if(i)
   			{
   				if(xa[i-1]>= xa[i]&& ya[i-1]>= ya[i]);
   				else fl=1;
   			}*/

   		}

   		if(fl )
   			{cout<<"NO\n";continue;}
   		cout<<"YES\n";
   		forr(n)
   		{
   			cout<<xa[i]<<" "<<ya[i]<<"\n";
   		}
   	}
    return 0;
}
/**/


#include <bits/stdc++.h>
using namespace std;
#define forr(n) for (int i=0;i<n;i++)
#define forx(x,n) for(int i=x;i<n;i++)
#define len(x,s) int x=s.length()
#define lenv(s) s.length()
#define pb push_back
#define endd(x) return x;
#define mems(a,v) memset(a,v,sizeof a)
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(),v.rend()
#define sfi(x) scanf("%d",&x)
#define sfi2(x,y) scanf("%i%i",&x,&y)
#define sfu(x) scanf("%hd",&x)
#define sfu2(x,y) scanf("%hd%hd",&x,&y)
#define mp(x,y) make_pair(x,y)
#define V vector
//#define nll cout<<endl;
#define nl cout<<endl
typedef long long ll;
typedef unsigned long long ull;
typedef unsigned int ui;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef pair<int, int> ii;
typedef vector<ii> vii;
typedef set<int> si;
typedef map<string, int> msi;
//int x[]={-1,0,1,-1,1,-1,0,1},y[]={-1,-1,-1,0,0,1,1,1};
#define MAX 1000000007
#define MOD 1000000007
#define oo 1e9
//string ans[]={"NO\n","YES\n"};
void printv(vector<int> v){forr(v.size())cout<<v[i]<<" ";cout<<endl;}
ull summ(ull n){return ((n*n)+n)/2;}
bool isubseq(string s,string s1){len(ln,s1);len(lll,s);int i=0,j=0;for(;i<ln&&j<lll;i++)j+=(s1[i]==s[j]);return j==lll;}
string to_string(int val){if(!val)return "0";string s;while(val){s+=val%10+48;val/=10;}reverse(s.begin(),s.end());return s;}
bool incirc(double x,double y, double center_x,double center_y,double r){return(x-center_x)*(x-center_x)+(y-center_y)*(y-center_y)<=r*r;}
ull gcd (ull a,ull b){ull c;while(a!=0){c=a;a=b%a;b=c;}return b;}
///Actual solution starts here/////////////////////Sherbi7y////////////////////////////////////////
ii lesser(int oi,int oj, int ti,int tj)
{
	if(oi <= ti && oj <= tj)
		return {oi,oj};
	if((oi >= ti && oj >= tj))
		return {ti, tj};

}
int main()
{
    ios_base::sync_with_stdio(0);cin.tie(0);//cout.tie(0);
    #ifndef ONLINE_JUDGE
        //freopen("A2.out","w",stdout);
        freopen("a1.in","r",stdin);
    #endif
   	int n;
   	bool fl=0;
   	while(cin>>n)
   	{
   		int xa[n],ya[n];
   		int xx,yy,mm,w;
   		ii o,t;
   		V< set<ii> > pintx(200010), pinty(200010);
   		forr(n)
   		{
   			cin>>xx>>yy;
   			mm=yy-xx;
   			pintx[mm+100000].insert({xx,yy});
   			pinty[mm+100000].insert({yy,xx});
   		}
   		forr(n)
   		{
   			//cout<<"f"<<endl;
   			cin>>w;
   			//cout<<w<<endl;
   			w+=100000;
   			if (pintx[w].empty())
   				{fl=1;}
   			o=*pintx[w].begin();
   			t=*pinty[w].begin();
   			o = lesser (o.first, o.second,t.second,t.first);
   			xa[i] = o.first;
   			ya[i] = o.second;
   			pintx[w].erase(o);
   			pinty[w].erase({o.second, o.first});
   		}
   		if(fl )
   			{cout<<"NO\n";continue;}
   		cout<<"YES\n";
   		forr(n)
   		{
   			cout<<xa[i]<<" "<<ya[i]<<"\n";
   		}
   	}
    return 0;
}
/**/


#include <bits/stdc++.h>
using namespace std;
#define forr(n) for (int i=0;i<n;i++)
#define forx(x,n) for(int i=x;i<n;i++)
#define len(x,s) int x=s.length()
#define lenv(s) s.length()
#define pb push_back
#define endd(x) return x;
#define mems(a,v) memset(a,v,sizeof a)
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(),v.rend()
#define sfi(x) scanf("%d",&x)
#define sfi2(x,y) scanf("%i%i",&x,&y)
#define sfu(x) scanf("%hd",&x)
#define sfu2(x,y) scanf("%hd%hd",&x,&y)
#define mp(x,y) make_pair(x,y)
#define V vector
//#define nll cout<<endl;
#define nl cout<<endl
typedef long long ll;
typedef unsigned long long ull;
typedef unsigned int ui;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef pair<int, int> ii;
typedef vector<ii> vii;
typedef set<int> si;
typedef map<string, int> msi;
//int x[]={-1,0,1,-1,1,-1,0,1},y[]={-1,-1,-1,0,0,1,1,1};
#define MAX 1000000007
#define MOD 1000000007
#define oo 1e9
//string ans[]={"NO\n","YES\n"};
void printv(vector<int> v){forr(v.size())cout<<v[i]<<" ";cout<<endl;}
ull summ(ull n){return ((n*n)+n)/2;}
bool isubseq(string s,string s1){len(ln,s1);len(lll,s);int i=0,j=0;for(;i<ln&&j<lll;i++)j+=(s1[i]==s[j]);return j==lll;}
string to_string(int val){if(!val)return "0";string s;while(val){s+=val%10+48;val/=10;}reverse(s.begin(),s.end());return s;}
bool incirc(double x,double y, double center_x,double center_y,double r){return(x-center_x)*(x-center_x)+(y-center_y)*(y-center_y)<=r*r;}
ull gcd (ull a,ull b){ull c;while(a!=0){c=a;a=b%a;b=c;}return b;}
///Actual solution starts here/////////////////////Sherbi7y////////////////////////////////////////
ii lesser(int oi,int oj, int ti,int tj)
{
    if(oi <= ti && oj <= tj)
        return {oi,oj};
    if((oi >= ti && oj >= tj))
        return {ti, tj};

}
int main()
{
    ios_base::sync_with_stdio(0);cin.tie(0);//cout.tie(0);
    #ifndef ONLINE_JUDGE
        //freopen("A2.out","w",stdout);
        freopen("a1.in","r",stdin);
    #endif
    int n;
    bool fl=0;
    while(cin>>n)
    {
        int xa[n],ya[n];
        int xx,yy,mm,w;
        ii o,t;
        V< set<ii> > pintx(200010), pinty(200010);
        forr(n)
        {
            cin>>xx>>yy;
            mm=yy-xx;
            pintx[mm+100000].insert({xx,yy});
            pinty[mm+100000].insert({yy,xx});
        }
        forr(n)
        {
            //cout<<"f"<<endl;
            cin>>w;
            //cout<<w<<endl;
            w+=100000;
            if (pintx[w].empty())
                {fl=1;}
            o=*pintx[w].begin();
            t=*pinty[w].begin();
            o = lesser (o.first, o.second,t.second,t.first);
            xa[i] = o.first;
            ya[i] = o.second;
            pintx[w].erase(o);
            pinty[w].erase({o.second, o.first});
        }
        for (int i=0;i<n-1;i++)
        {
            if(xa[i]>= xa[i+1]&& ya[i]>= ya[i+1])
            {
                fl=1;
                break;
            }
        }
        if(fl )
            {cout<<"NO\n";continue;}
        cout<<"YES\n";
        forr(n)
        {
            cout<<xa[i]<<" "<<ya[i]<<"\n";
        }
    }
    return 0;
}
/**/


/*#include <bits/stdc++.h>
using namespace std;
#define forr(n) for (int i=0;i<n;i++)
#define forx(x,n) for(int i=x;i<n;i++)
#define len(x,s) int x=s.length()
#define lenv(s) s.length()
#define pb push_back
#define endd(x) return x;
#define mems(a,v) memset(a,v,sizeof a)
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(),v.rend()
#define sfi(x) scanf("%d",&x)
#define sfi2(x,y) scanf("%i%i",&x,&y)
#define sfu(x) scanf("%hd",&x)
#define sfu2(x,y) scanf("%hd%hd",&x,&y)
#define mp(x,y) make_pair(x,y)
//#define nll cout<<endl;
#define nl cout<<endl
typedef long long ll;
typedef unsigned long long ull;
typedef unsigned int ui;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef pair<int, int> ii;
typedef vector<ii> vii;
typedef set<int> si;
typedef map<string, int> msi;
//int x[]={-1,0,1,-1,1,-1,0,1},y[]={-1,-1,-1,0,0,1,1,1};
#define MAX 1000000007
#define MOD 1000000007
#define oo 1e9
string ans[]={"NO\n","YES\n"};
void printv(vector<int> v){forr(v.size())cout<<v[i]<<" ";cout<<endl;}
ull summ(ull n){return ((n*n)+n)/2;}
bool isubseq(string s,string s1){len(ln,s1);len(lll,s);int i=0,j=0;for(;i<ln&&j<lll;i++)j+=(s1[i]==s[j]);return j==lll;}
string to_string(int val){if(!val)return "0";string s;while(val){s+=val%10+48;val/=10;}reverse(s.begin(),s.end());return s;}
bool incirc(double x,double y, double center_x,double center_y,double r){return(x-center_x)*(x-center_x)+(y-center_y)*(y-center_y)<=r*r;}
/// Actual solution starts here /////////////////////////////////////////////////////////////
int main()
{
    ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
    #ifndef ONLINE_JUDGE
        //freopen("A2.out","w",stdout);
        freopen("a1.in","r",stdin);
    #endif
    int n;
    while(cin>>n)
    {
        int arr[n];
        bool fl=1;
        forr(n)
        {
            cin>>arr[i];
        }
        forr(n)
        {
            for(int j=0;j<n;j++)
            {
                for(int k=j+1;k<n;k++)
                {
                    if(arr[i]== arr[j]+ arr[k])
                        {cout<<i+1<< " "<<j+1<<" "<<k+1<<"\n";fl=0;}
                }
            }
        }
        if(fl )
            cout<<"-1"<<endl;
        //cout<<minn<<"\n";
    }
    return 0;
}*/
    #include <iostream>
#include <stdio.h>
#include <algorithm>
#include <math.h>
#include <vector>
#include <cstring>
#include <string>
#include <queue>
#include <map>
#include <set>
#include <stdlib.h>
#include <ctime>
using namespace std;
#define forr(n) for(long long i=0;i<n;i++)
#define forrr(n) for(long long i=1;i<=n;i++)
#define forb(n) for(long long i=n;i>=0;i--)
typedef long long   ll;
typedef long double ld;

//vector<int> xi;

set<char> s2;
set<char> s3;
queue<ll> myqueue;
vector<ll> wi;
vector< vector<ll> > nums;
vector<ll> numbers;
vector<int> numbers4;

vector<string> V1;
vector<string> V2;
vector<int> set3;
vector<int> wrong;
vector< pair<ll, ll > > points;
vector< pair<ll, ll > > result;
//V.push_back(make_pair(temp1,temp2));
//scanf("%ld %ld\n", &data[p].first, &data[p].second);
vector< pair<int, string > > ypairV;
pair<int,int> ypair;

int main()
{
   //ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
    #ifndef ONLINE_JUDGE
    freopen("a1.in","r", stdin);
    //freopen("out.txt","w", stdout);
    #endif
    ll n,l=0,t=0,y=0,r=0,k=0,i=0,pos1=0,pointer=1,pos2=0,j=0,sum1=0,row=0,col=0,counter=0,temp,flag2=0,flag1=0,sum=0;
    cin>>n;
    forr(n)
    {
        cin>>temp>>flag1;
        points.push_back(make_pair(temp,flag1));
    }

    forr(n)
    {
        cin>>temp;
        wi.push_back(temp);
    }

    forr(wi.size())
    {
        temp = i;
        forr(points.size())
        {
            if((points[i].second - points[i].first)== wi[temp])
            {
                result.push_back(make_pair(points[i].first,points[i].second));
                points.erase(points.begin()+i);
                break;
            }
        }
    }
     if(result.size()<n)
        {
            cout<<"NO"<<endl;
            return 0;
        }
        for (int i=0;i<n-1;i++)
        {
            if(result[i].first >= result[i+1].first && result[i].second >= result[i+1].second)
            {
                //cout<<"a7a"<<endl;
                cout<<"NO"<<endl;
                break;
            }
        }

    cout<<"YES"<<endl;
    forr(result.size())
        cout<<result[i].first<<" "<<result[i].second<<endl;

    return 0;
}


#include <bits/stdc++.h>
using namespace std;
#define forr(n) for (int i=0;i<n;i++)
#define forx(x,n) for(int i=x;i<n;i++)
#define len(x,s) int x=s.length()
#define lenv(s) s.length()
#define pb push_back
#define endd(x) return x;
#define mems(a,v) memset(a,v,sizeof a)
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(),v.rend()
#define sfi(x) scanf("%d",&x)
#define sfi2(x,y) scanf("%i%i",&x,&y)
#define sfu(x) scanf("%hd",&x)
#define sfu2(x,y) scanf("%hd%hd",&x,&y)
#define mp(x,y) make_pair(x,y)
#define V vector
//#define nll cout<<endl;
#define nl cout<<endl
typedef long long ll;
typedef unsigned long long ull;
typedef unsigned int ui;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef pair<int, int> ii;
typedef vector<ii> vii;
typedef set<int> si;
typedef map<string, int> msi;
//int x[]={-1,0,1,-1,1,-1,0,1},y[]={-1,-1,-1,0,0,1,1,1};
#define MAX 1000000007
#define MOD 1000000007
#define oo 1e9
//string ans[]={"NO\n","YES\n"};
void printv(vector<int> v){forr(v.size())cout<<v[i]<<" ";cout<<endl;}
ull summ(ull n){return ((n*n)+n)/2;}
bool isubseq(string s,string s1){len(ln,s1);len(lll,s);int i=0,j=0;for(;i<ln&&j<lll;i++)j+=(s1[i]==s[j]);return j==lll;}
string to_string(int val){if(!val)return "0";string s;while(val){s+=val%10+48;val/=10;}reverse(s.begin(),s.end());return s;}
bool incirc(double x,double y, double center_x,double center_y,double r){return(x-center_x)*(x-center_x)+(y-center_y)*(y-center_y)<=r*r;}
ull gcd (ull a,ull b){ull c;while(a!=0){c=a;a=b%a;b=c;}return b;}
///Actual solution starts here/////////////////////Sherbi7y////////////////////////////////////////
ii lesser(int oi,int oj, int ti,int tj)
{
    if(oi <= ti && oj <= tj)
        return {oi,oj};
    if((oi >= ti && oj >= tj))
        return {ti, tj};
    if(oi < ti)
        return {oi,oj};
    return {ti, tj};
}
int main()
{
    ios_base::sync_with_stdio(0);cin.tie(0);//cout.tie(0);
    #ifndef ONLINE_JUDGE
        //freopen("A2.out","w",stdout);
        freopen("a1.in","r",stdin);
    #endif
    int n;
    bool fl=0;
    while(cin>>n)
    {
        int xa[n],ya[n];
        int xx,yy,mm,w;
        ii o,t;
        V< set<ii> > pintx(200010);
        forr(n)
        {
            cin>>xx>>yy;
            mm=yy-xx;
            pintx[mm+100000].insert({xx,yy});
        }
        forr(n)
        {
            //cout<<"f"<<endl;
            cin>>w;
            //cout<<w<<endl;
            w+=100000;
            if (pintx[w].empty())
                {fl=1;}
            o=*pintx[w].begin();
            xa[i] = o.first;
            ya[i] = o.second;
            pintx[w].erase(o);
            /*if(i)
            {
                if(xa[i-1]>= xa[i]&& ya[i-1]>= ya[i]);
                else fl=1;
            }*/

        }
        for (int i=0;i<n-1;i++)
        {
            if(xa[i]>= xa[i+1]&& ya[i]>= ya[i+1])
            {
                fl=1;
                break;
            }
        }
        if(fl )
            {cout<<"NO\n";continue;}
        cout<<"YES\n";
        forr(n)
        {
            cout<<xa[i]<<" "<<ya[i]<<"\n";
        }
    }
    return 0;
}
/**/


#include <bits/stdc++.h>
using namespace std;
#define forr(n) for (int i=0;i<n;i++)
#define forx(x,n) for(int i=x;i<n;i++)
#define len(x,s) int x=s.length()
#define lenv(s) s.length()
#define pb push_back
#define endd(x) return x;
#define mems(a,v) memset(a,v,sizeof a)
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(),v.rend()
#define sfi(x) scanf("%d",&x)
#define sfi2(x,y) scanf("%i%i",&x,&y)
#define sfu(x) scanf("%hd",&x)
#define sfu2(x,y) scanf("%hd%hd",&x,&y)
#define mp(x,y) make_pair(x,y)
#define V vector
//#define nll cout<<endl;
#define nl cout<<endl
typedef long long ll;
typedef unsigned long long ull;
typedef unsigned int ui;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef pair<int, int> ii;
typedef vector<ii> vii;
typedef set<int> si;
typedef map<string, int> msi;
//int x[]={-1,0,1,-1,1,-1,0,1},y[]={-1,-1,-1,0,0,1,1,1};
#define MAX 1000000007
#define MOD 1000000007
#define oo 1e9
//string ans[]={"NO\n","YES\n"};
void printv(vector<int> v){forr(v.size())cout<<v[i]<<" ";cout<<endl;}
ull summ(ull n){return ((n*n)+n)/2;}
bool isubseq(string s,string s1){len(ln,s1);len(lll,s);int i=0,j=0;for(;i<ln&&j<lll;i++)j+=(s1[i]==s[j]);return j==lll;}
string to_string(int val){if(!val)return "0";string s;while(val){s+=val%10+48;val/=10;}reverse(s.begin(),s.end());return s;}
bool incirc(double x,double y, double center_x,double center_y,double r){return(x-center_x)*(x-center_x)+(y-center_y)*(y-center_y)<=r*r;}
ull gcd (ull a,ull b){ull c;while(a!=0){c=a;a=b%a;b=c;}return b;}
///Actual solution starts here/////////////////////Sherbi7y////////////////////////////////////////
ii lesser(int oi,int oj, int ti,int tj)
{
    if(oi <= ti && oj <= tj)
        return {oi,oj};
    if((oi >= ti && oj >= tj))
        return {ti, tj};
    if(oi < ti)
        return {oi,oj};
    return {ti, tj};
}
int main()
{
    ios_base::sync_with_stdio(0);cin.tie(0);//cout.tie(0);
    #ifndef ONLINE_JUDGE
        //freopen("A2.out","w",stdout);
        freopen("a1.in","r",stdin);
    #endif
    int n;
    bool fl=0;
    while(cin>>n)
    {
        int xa[n],ya[n];
        int xx,yy,mm,w;
        ii o,t;
        V< set<ii> > pintx(200010), pinty(200010);
        forr(n)
        {
            cin>>xx>>yy;
            mm=yy-xx;
            pintx[mm+100000].insert({xx,yy});
            pinty[mm+100000].insert({yy,xx});
        }
        forr(n)
        {
            //cout<<"f"<<endl;
            cin>>w;
            //cout<<w<<endl;
            w+=100000;
            if (pintx[w].empty())
                {fl=1;}
            o=*pintx[w].begin();
            t=*pinty[w].begin();
            o = lesser (o.first, o.second,t.second,t.first);
            xa[i] = o.first;
            ya[i] = o.second;
            pintx[w].erase(o);
            pinty[w].erase({o.second, o.first});
            if(i)
            {
                if(xa[i]>= xa[i-1]&& ya[i]>= ya[i-1]);
                else fl=1;
            }
        }
        if(fl )
            {cout<<"NO\n";continue;}
        cout<<"YES\n";
        forr(n)
        {
            cout<<xa[i]<<" "<<ya[i]<<"\n";
        }
    }
    return 0;
}
/**/


#define _CRT_SECURE_NO_WARNINGS
#include <algorithm>
#include <iostream>
#include <stack>
#include <vector>
#include <string>
#include <cstdio>
#include <queue>
#include <set>
#include <map>
#include <cmath>
#include <cstring>
#include <cstdio>
#include <sstream>
#define eps 0.00000001
#define INF 1000000007
#define ll long long
#define ull unsigned long long

using namespace std;

template<class t>
void read(vector<t> & v)
{
for (int i = 0; i < v.size(); ++i)
cin >> v[i];
}

bool cmp(pair<int, int> a, pair<int, int> b)
{
	return (a.first + a.second) < (b.first + b.second);
}

void solve()
{
	int n;
	cin >> n;
	vector<pair<int, int> > v(n);
	map<int, queue<pair<int, int> > > m;
	for (int i = 0; i < n; ++i)
	{
		cin >> v[i].first >> v[i].second;
		m[v[i].second - v[i].first].push(v[i]);
	}
	vector<int> w(n);
	for (int i = 0; i < n; ++i)
	{
		cin >> w[i];
	}
	vector<pair<int, int> > ans;
	for (int i = 0; i < n; ++i)
	{
		if (m[w[i]].size() != 0)
		{
			ans.push_back(m[w[i]].front());
			m[w[i]].pop();
		}
		else
		{
			cout << "NO" << endl;
			return;
		}
	}
	if (ans.size() != n)
	{
		cout << "NO" << endl;
	}
	else
	{
		int mx = 0, my = 0;
		for (int i = 1; i < ans.size(); ++i)
		{
			if (ans[i-1].first < ans[i].first || (ans[i-1].first == ans[i-1].first && ans[i-1].second < ans[i].second))
			{
				//
			}
			else
			{
				cout << "NO" << endl;
				return;
			}
			mx = max(mx, ans[i].first);
			my = max(my, ans[i].second);
		}
		cout << "YES" << endl;
		for (int i = 0; i < ans.size(); ++i)
		{
			cout << ans[i].first << " " << ans[i].second << endl;
		}
	}
}

int main()
{
ios_base::sync_with_stdio(false);
solve();
return 0;
}


#define _CRT_SECURE_NO_WARNINGS
#include <algorithm>
#include <iostream>
#include <stack>
#include <vector>
#include <string>
#include <cstdio>
#include <queue>
#include <set>
#include <map>
#include <cmath>
#include <cstring>
#include <cstdio>
#include <sstream>
#define eps 0.00000001
#define INF 1000000007
#define ll long long
#define ull unsigned long long

using namespace std;

template<class t>
void read(vector<t> & v)
{
for (int i = 0; i < v.size(); ++i)
cin >> v[i];
}

bool cmp(pair<int, int> a, pair<int, int> b)
{
	return (a.first + a.second) < (b.first + b.second);
}

void solve()
{
	int n;
	cin >> n;
	vector<pair<int, int> > v(n);
	map<int, queue<pair<int, int> > > m;
	for (int i = 0; i < n; ++i)
	{
		cin >> v[i].first >> v[i].second;
		m[v[i].second - v[i].first].push(v[i]);
	}
	vector<int> w(n);
	for (int i = 0; i < n; ++i)
	{
		cin >> w[i];
	}
	vector<pair<int, int> > ans;
	for (int i = 0; i < n; ++i)
	{
		if (m[w[i]].size() != 0)
		{
			ans.push_back(m[w[i]].front());
			m[w[i]].pop();
		}
		else
		{
			cout << "NO" << endl;
			return;
		}
	}
	if (ans.size() != n)
	{
		cout << "NO" << endl;
	}
	else
	{
		int mx = 0, my = 0;
		for (int i = 1; i < ans.size(); ++i)
		{
			if (ans[i].first + ans[i].second < ans[i - 1].first + ans[i].second)
			{
				if (ans[i].first > mx) continue;
				if (ans[i].second > my) continue;
				cout << "NO" << endl;
				return;
			}
			mx = max(mx, ans[i].first);
			my = max(my, ans[i].second);
		}
		cout << "YES" << endl;
		for (int i = 0; i < ans.size(); ++i)
		{
			cout << ans[i].first << " " << ans[i].second << endl;
		}
	}
}

int main()
{
ios_base::sync_with_stdio(false);
solve();
return 0;
}


#define _CRT_SECURE_NO_WARNINGS
#include <algorithm>
#include <iostream>
#include <stack>
#include <vector>
#include <string>
#include <cstdio>
#include <queue>
#include <set>
#include <map>
#include <cmath>
#include <cstring>
#include <cstdio>
#include <sstream>
#define eps 0.00000001
#define INF 1000000007
#define ll long long
#define ull unsigned long long

using namespace std;

template<class t>
void read(vector<t> & v)
{
for (int i = 0; i < v.size(); ++i)
cin >> v[i];
}

bool cmp(pair<int, int> a, pair<int, int> b)
{
	return (a.first + a.second) < (b.first + b.second);
}

void solve()
{
	int n;
	cin >> n;
	vector<pair<int, int> > v(n);
	map<int, queue<pair<int, int> > > m;
	for (int i = 0; i < n; ++i)
	{
		cin >> v[i].first >> v[i].second;
		m[v[i].second - v[i].first].push(v[i]);
	}
	vector<int> w(n);
	for (int i = 0; i < n; ++i)
	{
		cin >> w[i];
	}
	vector<pair<int, int> > ans;
	for (int i = 0; i < n; ++i)
	{
		if (m[w[i]].size() != 0)
		{
			ans.push_back(m[w[i]].front());
			m[w[i]].pop();
		}
		else
		{
			cout << "NO" << endl;
			return;
		}
	}
	if (ans.size() != n)
	{
		cout << "NO" << endl;
	}
	else
	{
		int mx = 0, my = 0;
		for (int i = 1; i < ans.size(); ++i)
		{
			//if (ans[i].first + ans[i].second < ans[i - 1].first + ans[i].second)
			{
				if (ans[i].first > mx) continue;
				if (ans[i].second > my) continue;
				cout << "NO" << endl;
				return;
			}
			mx = max(mx, ans[i].first);
			my = max(my, ans[i].second);
		}
		cout << "YES" << endl;
		for (int i = 0; i < ans.size(); ++i)
		{
			cout << ans[i].first << " " << ans[i].second << endl;
		}
	}
}

int main()
{
ios_base::sync_with_stdio(false);
solve();
return 0;
}


#define _CRT_SECURE_NO_WARNINGS
#include <algorithm>
#include <iostream>
#include <stack>
#include <vector>
#include <string>
#include <cstdio>
#include <queue>
#include <set>
#include <map>
#include <cmath>
#include <cstring>
#include <cstdio>
#include <sstream>
#define eps 0.00000001
#define INF 1000000007
#define ll long long
#define ull unsigned long long

using namespace std;

template<class t>
void read(vector<t> & v)
{
	for (ll i = 0; i < v.size(); ++i)
		cin >> v[i];
}

bool cmp(pair<ll, ll> a, pair<ll, ll> b)
{
	return (a.first + a.second) < (b.first + b.second);
}

void solve()
{
	ll n;
	cin >> n;
	vector<pair<ll, ll> > v(n);
	map<ll, vector<pair<ll, ll> > > m;
	for (ll i = 0; i < n; ++i)
	{
		cin >> v[i].first >> v[i].second;
		m[v[i].second - v[i].first].push_back(v[i]);
	}
	for (auto & i : m)
	{
		sort(i.second.begin(), i.second.end(), cmp);
	}
	vector<ll> w(n);
	for (ll i = 0; i < n; ++i)
	{
		cin >> w[i];
	}
	vector<pair<ll, ll> > ans;
	map<int,int> pos;
	for (ll i = 0; i < n; ++i)
	{
		if (m[w[i]].size() != 0)
		{
			ans.push_back(m[w[i]][pos[w[i]]]);
			++pos[w[i]];
		}
		else
		{
			cout << "NO" << endl;
			return;
		}
	}
	if (ans.size() != n)
	{
		cout << "NO" << endl;
	}
	else
	{
		ll mx = 0, my = 0;
		for (ll i = 1; i < ans.size(); ++i)
		{
			if (ans[i - 1].first < ans[i].first || (ans[i - 1].first == ans[i - 1].first && ans[i - 1].second < ans[i].second))
			{
				//
			}
			else
			{
				cout << "NO" << endl;
				return;
			}
			mx = max(mx, ans[i].first);
			my = max(my, ans[i].second);
		}
		cout << "YES" << endl;
		for (ll i = 0; i < ans.size(); ++i)
		{
			cout << ans[i].first << " " << ans[i].second << endl;
		}
	}
}

int main()
{
	ios_base::sync_with_stdio(false);
	solve();
	return 0;
}


#define _CRT_SECURE_NO_WARNINGS
#include <algorithm>
#include <iostream>
#include <stack>
#include <vector>
#include <string>
#include <cstdio>
#include <queue>
#include <set>
#include <map>
#include <cmath>
#include <cstring>
#include <cstdio>
#include <sstream>
#define eps 0.00000001
#define INF 1000000007
#define ll long long
#define ull unsigned long long

using namespace std;

template<class t>
void read(vector<t> & v)
{
for (ll i = 0; i < v.size(); ++i)
cin >> v[i];
}

bool cmp(pair<ll, ll> a, pair<ll, ll> b)
{
	return (a.first + a.second) < (b.first + b.second);
}

void solve()
{
	ll n;
	cin >> n;
	vector<pair<ll, ll> > v(n);
	map<ll, queue<pair<ll, ll> > > m;
	for (ll i = 0; i < n; ++i)
	{
		cin >> v[i].first >> v[i].second;
		m[v[i].second - v[i].first].push(v[i]);
	}
	vector<ll> w(n);
	for (ll i = 0; i < n; ++i)
	{
		cin >> w[i];
	}
	vector<pair<ll, ll> > ans;
	for (ll i = 0; i < n; ++i)
	{
		if (m[w[i]].size() != 0)
		{
			ans.push_back(m[w[i]].front());
			m[w[i]].pop();
		}
		else
		{
			cout << "NO" << endl;
			return;
		}
	}
	if (ans.size() != n)
	{
		cout << "NO" << endl;
	}
	else
	{
		ll mx = 0, my = 0;
		for (ll i = 1; i < ans.size(); ++i)
		{
			if (ans[i-1].first < ans[i].first || (ans[i-1].first == ans[i-1].first && ans[i-1].second < ans[i].second))
			{
				//
			}
			else
			{
				cout << "NO" << endl;
				return;
			}
			mx = max(mx, ans[i].first);
			my = max(my, ans[i].second);
		}
		cout << "YES" << endl;
		for (ll i = 0; i < ans.size(); ++i)
		{
			cout << ans[i].first << " " << ans[i].second << endl;
		}
	}
}

int main()
{
ios_base::sync_with_stdio(false);
solve();
return 0;
}


#define _CRT_SECURE_NO_WARNINGS
#include <algorithm>
#include <iostream>
#include <stack>
#include <vector>
#include <string>
#include <cstdio>
#include <queue>
#include <set>
#include <map>
#include <cmath>
#include <cstring>
#include <cstdio>
#include <sstream>
#define eps 0.00000001
#define INF 1000000007
#define ll long long
#define ull unsigned long long

using namespace std;

template<class t>
void read(vector<t> & v)
{
for (int i = 0; i < v.size(); ++i)
cin >> v[i];
}

bool cmp(pair<int, int> a, pair<int, int> b)
{
	return (a.first + a.second) < (b.first + b.second);
}

void solve()
{
	int n;
	cin >> n;
	vector<pair<int, int> > v(n);
	map<int, queue<pair<int, int> > > m;
	for (int i = 0; i < n; ++i)
	{
		cin >> v[i].first >> v[i].second;
		m[v[i].second - v[i].first].push(v[i]);
	}
	vector<int> w(n);
	for (int i = 0; i < n; ++i)
	{
		cin >> w[i];
	}
	vector<pair<int, int> > ans;
	for (int i = 0; i < n; ++i)
	{
		if (m[w[i]].size() != 0)
		{
			ans.push_back(m[w[i]].front());
			m[w[i]].pop();
		}
		else
		{
			cout << "NO" << endl;
			return;
		}
	}
	if (ans.size() != n)
	{
		cout << "NO" << endl;
	}
	else
	{
		int mx = 0, my = 0;
		for (int i = 1; i < ans.size(); ++i)
		{
			if (ans[i].first + ans[i].second < ans[i - 1].first + ans[i].second)
			{
				if (ans[i].first >= mx) continue;
				if (ans[i].second >= my) continue;
				cout << "NO" << endl;
				return;
			}
			mx = max(mx, ans[i].first);
			my = max(my, ans[i].second);
		}
		cout << "YES" << endl;
		for (int i = 0; i < ans.size(); ++i)
		{
			cout << ans[i].first << " " << ans[i].second << endl;
		}
	}
}

int main()
{
ios_base::sync_with_stdio(false);
solve();
return 0;
}


#include <bits/stdc++.h>

using namespace std;

#define pb push_back
#define mp make_pair
#define y1 lalalalala
#define index lalalalalala
#define show(a, i) cout << " a[ " << i << " ] = " << a[i] << endl;
#define all(x) x.begin(), x.end()
#define vi vector<int>
#define pii pair<int, int>
#define ll long long
#define pdd pair<double, double>

#define si(x) scanf("%d", &x)
#define out(x) printf("%d\n", x);

const int cs = 0x186A1;

int n;
pii a[cs];
int w[cs], ans[cs];
int p = -1 << 30, q = p;
map<int, queue<int> > m;

bool cmp(pii a, pii b)
{
    int dif1 = a.second - a.first;
    int dif2 = b.second - b.first;

    if(dif1 != dif2)
        return dif1 < dif2;
    return a.first < b.first;
}
int main()
{
    //ios_base:: sync_with_stdio(false);
    //cin.tie(false);

    si(n);

    for(int i = 1 ; i <= n ; i ++)
    {
        si(a[i].first);
        si(a[i].second);
    }

    sort(a + 1, a + n + 1, cmp);

    for(int i = 1 ; i <= n ; i ++)
        si(w[i]);

    for(int i = 1 ; i <= n ; i ++)
        m[ a[i].second - a[i].first ].push(i);

    for(int i = 1 ; i <= n ; i ++)
    {
        if(m[ w[i] ].empty())
        {
            cout << "NO" << endl;
            return 0;
        }
        ans[i] = m[ w[i] ].front();

        int ff = a[ ans[i] ].first, ss = a[ ans[i] ].second;
        if(ff < p && ss < q)
        {
            cout << "NO" << endl;
            return 0;
        }
        if(ff > p)
            p = ff;
        if(ss > q)
            q = ss;

        m[ w[i] ].pop();
    }

    cout << "YES" << endl;
    for(int i = 1 ; i <= n ; i ++)
        cout << a[ ans[i] ].first << " " << a[ ans[i] ].second << endl;
    ///cout << "Elapsed time is: " << clock() / CLOCKS_PER_SEC << endl;
    return 0;
}


#include <bits/stdc++.h>

using namespace std;

#define pb push_back
#define mp make_pair
#define y1 lalalalala
#define index lalalalalala
#define show(a, i) cout << " a[ " << i << " ] = " << a[i] << endl;
#define all(x) x.begin(), x.end()
#define vi vector<int>
#define pii pair<int, int>
#define ll long long
#define pdd pair<double, double>

#define si(x) scanf("%d", &x)
#define out(x) printf("%d\n", x);

const int cs = 0x186A1;

int n;
pii a[cs];
int w[cs], ans[cs];
map<int, queue<int> > m;

bool cmp(pii a, pii b)
{
    return a.second - a.first < b.second - b.first;
}
int main()
{
    //ios_base:: sync_with_stdio(false);
    //cin.tie(false);

    si(n);

    for(int i = 1 ; i <= n ; i ++)
    {
        si(a[i].first);
        si(a[i].second);
    }

    sort(a + 1, a + n + 1, cmp);

    for(int i = 1 ; i <= n ; i ++)
        si(w[i]);

    for(int i = 1 ; i <= n ; i ++)
        m[ a[i].second - a[i].first ].push(i);

    for(int i = 1 ; i <= n ; i ++)
    {
        if(m[ w[i] ].empty())
        {
            cout << "NO" << endl;
            return 0;
        }
        ans[i] = m[ w[i] ].front();
        m[ w[i] ].pop();
    }

    cout << "YES" << endl;
    for(int i = 1 ; i <= n ; i ++)
        cout << a[ ans[i] ].first << " " << a[ ans[i] ].second << endl;
    ///cout << "Elapsed time is: " << clock() / CLOCKS_PER_SEC << endl;
    return 0;
}


#include <bits/stdc++.h>

using namespace std;

#define pb push_back
#define mp make_pair
#define y1 lalalalala
#define index lalalalalala
#define show(a, i) cout << " a[ " << i << " ] = " << a[i] << endl;
#define all(x) x.begin(), x.end()
#define vi vector<int>
#define pii pair<int, int>
#define ll long long
#define pdd pair<double, double>

#define si(x) scanf("%d", &x)
#define out(x) printf("%d\n", x);

const int cs = 0x186A1;

int n;
pii a[cs];
int w[cs], ans[cs];
int p = -1 << 30, q = p;
map<int, queue<int> > m;

bool cmp(pii a, pii b)
{
    int dif1 = a.second - a.first;
    int dif2 = b.second - b.first;

    if(dif1 != dif2)
        return dif1 < dif2;
    return a.first < b.first;
}
int main()
{
    //ios_base:: sync_with_stdio(false);
    //cin.tie(false);

    si(n);

    for(int i = 1 ; i <= n ; i ++)
    {
        si(a[i].first);
        si(a[i].second);
    }

    sort(a + 1, a + n + 1, cmp);

    for(int i = 1 ; i <= n ; i ++)
        si(w[i]);

    for(int i = 1 ; i <= n ; i ++)
        m[ a[i].second - a[i].first ].push(i);

    for(int i = 1 ; i <= n ; i ++)
    {
        if(m[ w[i] ].empty())
        {
            cout << "NO" << endl;
            return 0;
        }
        ans[i] = m[ w[i] ].front();

        int ff = a[ ans[i] ].first, ss = a[ ans[i].second ];
        if(ff < p && ss < q)
        {
            cout << "NO" << endl;
            return 0;
        }
        if(ff >= p && ss >= q)
        {
            p = ff;
            q = ss;
        }
        m[ w[i] ].pop();
    }

    cout << "YES" << endl;
    for(int i = 1 ; i <= n ; i ++)
        cout << a[ ans[i] ].first << " " << a[ ans[i] ].second << endl;
    ///cout << "Elapsed time is: " << clock() / CLOCKS_PER_SEC << endl;
    return 0;
}


#include <bits/stdc++.h>

using namespace std;

#define pb push_back
#define mp make_pair
#define y1 lalalalala
#define index lalalalalala
#define show(a, i) cout << " a[ " << i << " ] = " << a[i] << endl;
#define all(x) x.begin(), x.end()
#define vi vector<int>
#define pii pair<int, int>
#define ll long long
#define pdd pair<double, double>

#define si(x) scanf("%d", &x)
#define out(x) printf("%d\n", x);

const int cs = 0x186A1;

int n;
pii a[cs];
int w[cs], ans[cs];
map<int, queue<int> > m;

int main()
{
    //ios_base:: sync_with_stdio(false);
    //cin.tie(false);

    si(n);

    for(int i = 1 ; i <= n ; i ++)
    {
        si(a[i].first);
        si(a[i].second);
    }

    sort(a + 1, a + n + 1);

    for(int i = 1 ; i <= n ; i ++)
        si(w[i]);

    for(int i = 1 ; i <= n ; i ++)
        m[ a[i].second - a[i].first ].push(i);

    for(int i = 1 ; i <= n ; i ++)
    {
        if(m[ w[i] ].empty())
        {
            cout << "NO" << endl;
            return 0;
        }
        ans[i] = m[ w[i] ].front();
        m[ w[i] ].pop();
    }

    cout << "YES" << endl;
    for(int i = 1 ; i <= n ; i ++)
        cout << a[ ans[i] ].first << " " << a[ ans[i] ].second << endl;
    ///cout << "Elapsed time is: " << clock() / CLOCKS_PER_SEC << endl;
    return 0;
}


#include <bits/stdc++.h>

using namespace std;

#define pb push_back
#define mp make_pair
#define y1 lalalalala
#define index lalalalalala
#define show(a, i) cout << " a[ " << i << " ] = " << a[i] << endl;
#define all(x) x.begin(), x.end()
#define vi vector<int>
#define pii pair<int, int>
#define ll long long
#define pdd pair<double, double>

#define si(x) scanf("%d", &x)
#define out(x) printf("%d\n", x);

const int cs = 0x186A1;

int n;
pii a[cs];
int w[cs], ans[cs];
int p = -1 << 30, q = p;
map<int, queue<int> > m;
map< pii, int> ft;

bool cmp(pii a, pii b)
{
    int dif1 = a.second - a.first;
    int dif2 = b.second - b.first;

    if(dif1 != dif2)
        return dif1 < dif2;
    return a.first < b.first;
}

void add(int x, int y)
{
    while(x > 0)
    {
        int tempy = y;

        while(tempy > 0)
        {
            ft[ {x, tempy} ] = 1;
            tempy -= (tempy & -tempy);
        }
        x -= (x & -x);
    }
}

int get(int x, int y)
{
    int s = 1;

    while(x > 0 && s)
    {
        int tempy = y;

        while(tempy > 0 && s)
        {
            s &= (ft[ {x, tempy} ]);
            tempy -= (tempy & -tempy);
        }
        x -= (x & -x);
    }

    return s;
}
int main()
{
    //ios_base:: sync_with_stdio(false);
    //cin.tie(false);

    si(n);

    for(int i = 1 ; i <= n ; i ++)
    {
        si(a[i].first);
        si(a[i].second);
    }

    sort(a + 1, a + n + 1, cmp);

    for(int i = 1 ; i <= n ; i ++)
        si(w[i]);

    for(int i = 1 ; i <= n ; i ++)
        m[ a[i].second - a[i].first ].push(i);

    for(int i = 1 ; i <= n ; i ++)
    {
        if(m[ w[i] ].empty())
        {
            cout << "NO" << endl;
            return 0;
        }
        ans[i] = m[ w[i] ].front();

        int p = a[ ans[i] ].first + 10, q = a[ ans[i] ].second + 10;
        if(get(p, q) == 1)
        {
            cout << "NO" << endl;
            return 0;
        }
        add(p, q);
        m[ w[i] ].pop();
    }

    cout << "YES" << endl;
    for(int i = 1 ; i <= n ; i ++)
        cout << a[ ans[i] ].first << " " << a[ ans[i] ].second << endl;
    ///cout << "Elapsed time is: " << clock() / CLOCKS_PER_SEC << endl;
    return 0;
}


#include <bits/stdc++.h>

using namespace std;

#define pb push_back
#define mp make_pair
#define y1 lalalalala
#define index lalalalalala
#define show(a, i) cout << " a[ " << i << " ] = " << a[i] << endl;
#define all(x) x.begin(), x.end()
#define vi vector<int>
#define pii pair<int, int>
#define ll long long
#define pdd pair<double, double>

#define si(x) scanf("%d", &x)
#define out(x) printf("%d\n", x);

const int cs = 0x186A1;

int n;
pii a[cs];
int w[cs], ans[cs];
map<int, queue<int> > m;

int main()
{
    //ios_base:: sync_with_stdio(false);
    //cin.tie(false);

    si(n);

    for(int i = 1 ; i <= n ; i ++)
    {
        si(a[i].first);
        si(a[i].second);
    }

    for(int i = 1 ; i <= n ; i ++)
        si(w[i]);

    for(int i = 1 ; i <= n ; i ++)
        m[ a[i].second - a[i].first ].push(i);

    for(int i = 1 ; i <= n ; i ++)
    {
        if(m[ w[i] ].empty())
        {
            cout << "NO" << endl;
            return 0;
        }
        ans[i] = m[ w[i] ].front();
        m[ w[i] ].pop();
    }

    cout << "YES" << endl;
    for(int i = 1 ; i <= n ; i ++)
        cout << a[ ans[i] ].first << " " << a[ ans[i] ].second << endl;
    ///cout << "Elapsed time is: " << clock() / CLOCKS_PER_SEC << endl;
    return 0;
}


#include <bits/stdc++.h>

using namespace std;

#define pb push_back
#define mp make_pair
#define y1 lalalalala
#define index lalalalalala
#define show(a, i) cout << " a[ " << i << " ] = " << a[i] << endl;
#define all(x) x.begin(), x.end()
#define vi vector<int>
#define pii pair<int, int>
#define ll long long
#define pdd pair<double, double>

#define si(x) scanf("%d", &x)
#define out(x) printf("%d\n", x);

const int cs = 0x186A1;

int n;
pii a[cs];
int w[cs], ans[cs];
int p = -1 << 30, q = p;
map<int, queue<int> > m;
map< pii, int> ft;

bool cmp(pii a, pii b)
{
    int dif1 = a.second - a.first;
    int dif2 = b.second - b.first;

    if(dif1 != dif2)
        return dif1 < dif2;
    return a.first < b.first;
}

void add(int x, int y)
{
    while(x > 0)
    {
        int tempy = y;

        while(tempy > 0)
        {
            ft[ {x, tempy} ] = 1;
            tempy -= (tempy & -tempy);
        }
        x -= (x & -x);
    }
}

int get(int x, int y)
{
    int s = 1;

    while(x > 0 && s)
    {
        int tempy = y;

        while(tempy > 0 && s)
        {
            s &= (ft[ {x, tempy} ]);
            tempy -= (tempy & -tempy);
        }
        x -= (x & -x);
    }
}
int main()
{
    //ios_base:: sync_with_stdio(false);
    //cin.tie(false);

    si(n);

    for(int i = 1 ; i <= n ; i ++)
    {
        si(a[i].first);
        si(a[i].second);
    }

    sort(a + 1, a + n + 1, cmp);

    for(int i = 1 ; i <= n ; i ++)
        si(w[i]);

    for(int i = 1 ; i <= n ; i ++)
        m[ a[i].second - a[i].first ].push(i);

    for(int i = 1 ; i <= n ; i ++)
    {
        if(m[ w[i] ].empty())
        {
            cout << "NO" << endl;
            return 0;
        }
        ans[i] = m[ w[i] ].front();

        int p = a[ ans[i] ].first + 10, q = a[ ans[i] ].second + 10;
        if(get(p, q) == 1)
        {
            cout << "NO" << endl;
            return 0;
        }
        add(p, q);
        m[ w[i] ].pop();
    }

    cout << "YES" << endl;
    for(int i = 1 ; i <= n ; i ++)
        cout << a[ ans[i] ].first << " " << a[ ans[i] ].second << endl;
    ///cout << "Elapsed time is: " << clock() / CLOCKS_PER_SEC << endl;
    return 0;
}


#include <bits/stdc++.h>

using namespace std;

#define pb push_back
#define mp make_pair
#define y1 lalalalala
#define index lalalalalala
#define show(a, i) cout << " a[ " << i << " ] = " << a[i] << endl;
#define all(x) x.begin(), x.end()
#define vi vector<int>
#define pii pair<int, int>
#define ll long long
#define pdd pair<double, double>

#define si(x) scanf("%d", &x)
#define out(x) printf("%d\n", x);

const int cs = 0x186A1;

int n;
pii a[cs];
int w[cs], ans[cs];
map<int, queue<int> > m;

bool cmp(pii a, pii b)
{
    int dif1 = a.second - a.first;
    int dif2 = b.second - b.first;

    if(dif1 != dif2)
        return dif1 < dif2;
    return a.first < b.first;
}
int main()
{
    //ios_base:: sync_with_stdio(false);
    //cin.tie(false);

    si(n);

    for(int i = 1 ; i <= n ; i ++)
    {
        si(a[i].first);
        si(a[i].second);
    }

    sort(a + 1, a + n + 1, cmp);

    for(int i = 1 ; i <= n ; i ++)
        si(w[i]);

    for(int i = 1 ; i <= n ; i ++)
        m[ a[i].second - a[i].first ].push(i);

    for(int i = 1 ; i <= n ; i ++)
    {
        if(m[ w[i] ].empty())
        {
            cout << "NO" << endl;
            return 0;
        }
        ans[i] = m[ w[i] ].front();
        m[ w[i] ].pop();
    }

    cout << "YES" << endl;
    for(int i = 1 ; i <= n ; i ++)
        cout << a[ ans[i] ].first << " " << a[ ans[i] ].second << endl;
    ///cout << "Elapsed time is: " << clock() / CLOCKS_PER_SEC << endl;
    return 0;
}


#include <bits/stdc++.h>

using namespace std;

#define pb push_back
#define mp make_pair
#define y1 lalalalala
#define index lalalalalala
#define show(a, i) cout << " a[ " << i << " ] = " << a[i] << endl;
#define all(x) x.begin(), x.end()
#define vi vector<int>
#define pii pair<int, int>
#define ll long long
#define pdd pair<double, double>

#define si(x) scanf("%d", &x)
#define out(x) printf("%d\n", x);

const int cs = 0x186A1;

int n;
pii a[cs];
int w[cs], ans[cs];
int p = -1 << 30, q = p;
map<int, queue<int> > m;

bool cmp(pii a, pii b)
{
    int dif1 = a.second - a.first;
    int dif2 = b.second - b.first;

    if(dif1 != dif2)
        return dif1 < dif2;
    return a.first < b.first;
}
int main()
{
    //ios_base:: sync_with_stdio(false);
    //cin.tie(false);

    si(n);

    for(int i = 1 ; i <= n ; i ++)
    {
        si(a[i].first);
        si(a[i].second);
    }

    sort(a + 1, a + n + 1, cmp);

    for(int i = 1 ; i <= n ; i ++)
        si(w[i]);

    for(int i = 1 ; i <= n ; i ++)
        m[ a[i].second - a[i].first ].push(i);

    for(int i = 1 ; i <= n ; i ++)
    {
        if(m[ w[i] ].empty())
        {
            cout << "NO" << endl;
            return 0;
        }
        ans[i] = m[ w[i] ].front();

        int ff = a[ ans[i] ].first, ss = a[ ans[i] ].second;
        if(ff < p && ss < q)
        {
            cout << "NO" << endl;
            return 0;
        }
        if(ff >= p && ss >= q)
        {
            p = ff;
            q = ss;
        }
        m[ w[i] ].pop();
    }

    cout << "YES" << endl;
    for(int i = 1 ; i <= n ; i ++)
        cout << a[ ans[i] ].first << " " << a[ ans[i] ].second << endl;
    ///cout << "Elapsed time is: " << clock() / CLOCKS_PER_SEC << endl;
    return 0;
}