#include <bits/stdc++.h>
using namespace std;
template <class T>
struct Point {
  T x, y;
  explicit Point(T x = 0, T y = 0) : x(x), y(y) {}
  bool operator<(Point p) const { return tie(x, y) < tie(p.x, p.y); }
  bool operator==(Point p) const { return tie(x, y) == tie(p.x, p.y); }
  Point operator+(Point p) const { return Point(x + p.x, y + p.y); }
  Point operator-(Point p) const { return Point(x - p.x, y - p.y); }
  Point operator*(T d) const { return Point(x * d, y * d); }
  Point operator/(T d) const { return Point(x / d, y / d); }
  T dot(Point p) const { return x * p.x + y * p.y; }
  T cross(Point p) const { return x * p.y - y * p.x; }
  T cross(Point a, Point b) const { return (a - *this).cross(b - *this); }
  T dist2() const { return x * x + y * y; }
  double dist() const { return sqrt((double)dist2()); }
  double angle() const { return atan2(y, x); }
  Point unit() const { return *this / dist(); }
  Point perp() const { return Point(-y, x); }
  Point normal() const { return perp().unit(); }
  Point rotate(double a) const {
    return Point(x * cos(a) - y * sin(a), x * sin(a) + y * cos(a));
  }
};
pair<vector<int>, vector<int> > ulHull(const vector<Point<long long> >& S) {
  vector<int> Q((int)(S).size()), U, L;
  iota(Q.begin(), Q.end(), 0);
  sort(Q.begin(), Q.end(), [&S](int a, int b) { return S[a] < S[b]; });
  for (auto& it : Q) {
    while ((int)(U).size() > 1 &&
           S[U[(int)(U).size() - 2]].cross(S[it], S[U.back()]) <= 0)
      U.pop_back();
    U.push_back(it);
    ;
    while ((int)(L).size() > 1 &&
           S[L[(int)(L).size() - 2]].cross(S[it], S[L.back()]) >= 0)
      L.pop_back();
    L.push_back(it);
    ;
  }
  return {U, L};
}
vector<int> convexHull(const vector<Point<long long> >& S) {
  vector<int> u, l;
  tie(u, l) = ulHull(S);
  if ((int)(S).size() <= 1) return u;
  if (S[u[0]] == S[u[1]]) return {0};
  l.insert(l.end(), u.rbegin() + 1, u.rend() - 1);
  return l;
}
vector<Point<long long> > pa;
vector<Point<long long> > pb;
vector<int> degb;
void solve(vector<int>& cura, vector<int>& curb) {
  if (cura.size() + curb.size() <= 1) return;
  {
    vector<int> s;
    {
      vector<Point<long long> > pts;
      for (int x : cura) {
        pts.push_back(pa[x]);
      }
      for (int x : curb) {
        pts.push_back(pb[x]);
      }
      s = convexHull(pts);
    }
    int hasred = 0;
    int hasblue = 0;
    for (int i = 0; i < s.size(); i++) {
      if (s[i] < cura.size()) {
        hasred = 1;
      } else {
        hasblue = 1;
      }
    }
    for (int i = 0; i < s.size(); i++) {
      if (s[i] < cura.size() && s[(i + 1) % s.size()] >= cura.size()) {
        int ai = cura[s[i]];
        int bi = curb[s[(i + 1) % s.size()] - cura.size()];
        cout << bi + 1 << " " << ai + 1 << '\n';
        if (degb[bi] == 1) {
          vector<int> newb;
          degb[bi]--;
          for (int b : curb) {
            if (b == bi) continue;
            newb.push_back(b);
          }
          s.clear();
          s.shrink_to_fit();
          curb.clear();
          curb.shrink_to_fit();
          solve(cura, newb);
          return;
        } else {
          vector<int> newa;
          degb[bi]--;
          for (int a : cura) {
            if (a == ai) continue;
            newa.push_back(a);
          }
          s.clear();
          s.shrink_to_fit();
          cura.clear();
          cura.shrink_to_fit();
          solve(newa, curb);
          return;
        }
      }
    }
    assert(hasred == 0 || hasblue == 0);
  }
  vector<pair<Point<long long>, int> > spoints;
  for (int a : cura) {
    spoints.emplace_back(pa[a], a);
  }
  for (int b : curb) {
    spoints.emplace_back(pb[b], pa.size() + b);
  }
  sort(spoints.begin(), spoints.end());
  int psum = 0;
  for (int i = 0; i < spoints.size(); i++) {
    int newpsum = psum;
    if (spoints[i].second < pa.size()) {
      newpsum -= 1;
    } else {
      newpsum += degb[spoints[i].second - pa.size()] - 1;
    }
    if (i > 0 && i + 1 < spoints.size()) {
      if (psum >= 0 && newpsum < 0) {
        vector<int> lefta, righta, leftb, rightb;
        for (int j = 0; j <= i; j++) {
          if (spoints[j].second < pa.size()) {
            lefta.push_back(spoints[j].second);
          } else {
            int b = spoints[j].second - pa.size();
            leftb.push_back(b);
          }
        }
        for (int j = i; j < spoints.size(); j++) {
          if (spoints[j].second < pa.size()) {
            righta.push_back(spoints[j].second);
          } else {
            int b = spoints[j].second - pa.size();
            rightb.push_back(b);
          }
        }
        cura.clear();
        cura.shrink_to_fit();
        curb.clear();
        curb.shrink_to_fit();
        spoints.clear();
        spoints.shrink_to_fit();
        solve(lefta, leftb);
        solve(righta, rightb);
        return;
      }
      if (psum < 0 && newpsum >= 0) {
        vector<int> lefta, righta, leftb, rightb;
        for (int j = 0; j <= i; j++) {
          if (spoints[j].second < pa.size()) {
            lefta.push_back(spoints[j].second);
          } else {
            int b = spoints[j].second - pa.size();
            leftb.push_back(b);
          }
        }
        for (int j = i; j < spoints.size(); j++) {
          if (spoints[j].second < pa.size()) {
            righta.push_back(spoints[j].second);
          } else {
            int b = spoints[j].second - pa.size();
            rightb.push_back(b);
          }
        }
        int b = spoints[i].second - pa.size();
        int ldeg = -psum;
        int rdeg = newpsum + 1;
        assert(ldeg + rdeg == degb[b]);
        cura.clear();
        cura.shrink_to_fit();
        curb.clear();
        curb.shrink_to_fit();
        spoints.clear();
        spoints.shrink_to_fit();
        degb[b] = ldeg;
        solve(lefta, leftb);
        degb[b] = rdeg;
        solve(righta, rightb);
        return;
      }
    }
    psum = newpsum;
  }
}
int main() {
  cin.sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  int T;
  cin >> T;
  for (int t = 0; t < T; t++) {
    int a, b;
    cin >> a >> b;
    degb.resize(b);
    for (int i = 0; i < b; i++) {
      cin >> degb[i];
    }
    pa.resize(a);
    pb.resize(b);
    for (int i = 0; i < a; i++) {
      cin >> pa[i].x >> pa[i].y;
    }
    for (int i = 0; i < b; i++) {
      cin >> pb[i].x >> pb[i].y;
    }
    cout << "YES" << '\n';
    vector<int> cura;
    vector<int> curb;
    for (int i = 0; i < a; i++) {
      cura.push_back(i);
    }
    for (int i = 0; i < b; i++) {
      curb.push_back(i);
    }
    solve(cura, curb);
  }
}
