#include <bits/stdc++.h>
using namespace std;
const long double pi = acos(-1);
const long double eps = 1e-9;
struct Point {
  int x, y, id, deg;
  Point(int _x = 0, int _y = 0, int _id = 0, int _deg = 0)
      : x(_x), y(_y), id(_id), deg(_deg) {}
  inline bool operator<(const Point &rhs) const { return deg < rhs.deg; }
  inline bool operator!=(const Point &rhs) const { return id != rhs.id; }
};
int T, N, M;
inline void solve(vector<Point> p) {
  register int i;
  Point mx;
  for (i = 0; i < p.size(); ++i)
    if (mx.deg < p[i].deg) mx.deg = p[i].deg, mx.id = i;
  if (mx.deg == 1) {
    for (i = 0; i < p.size(); ++i)
      if (!p[i].deg) mx.id = i;
    for (i = 0; i < p.size(); ++i) {
      if (i != mx.id) printf("%d %d\n", p[i].id + 1, p[mx.id].id + 1);
    }
    return;
  }
  int n = p.size() - 1;
  swap(p[mx.id], p[n]);
  vector<pair<long double, int> > a;
  for (i = 0; i < n; ++i) {
    long double from = atan2(p[i].y - p[n].y, p[i].x - p[n].x);
    long double to = from + pi;
    if (to > pi) to -= pi * 2.0;
    a.emplace_back(from, i);
    a.emplace_back(to, n + i);
  }
  sort(a.begin(), a.end());
  vector<bool> side(n);
  int sum = 0;
  for (auto A : a) {
    if (A.first > eps && A.second < n)
      sum += p[A.second].deg - 1, side[A.second] = true;
  }
  for (auto A : a) {
    if (sum <= -1 && sum >= 1 - mx.deg) break;
    if (A.second < n)
      sum += p[A.second].deg - 1, side[A.second] = true;
    else
      sum -= p[A.second - n].deg - 1, side[A.second - n] = false;
  }
  vector<Point> left, right;
  for (i = 0; i < n; ++i) (side[i] ? left : right).emplace_back(p[i]);
  left.emplace_back(p[n].x, p[n].y, p[n].id, -sum);
  right.emplace_back(p[n].x, p[n].y, p[n].id, sum + mx.deg);
  solve(left);
  solve(right);
}
int main() {
  register int i;
  scanf("%d", &T);
  while (T--) {
    scanf("%d%d", &N, &M);
    vector<int> deg(M);
    vector<Point> p(N + M);
    for (i = 0; i < M; ++i) scanf("%d", &deg[i]);
    for (i = 0; i < N; ++i) scanf("%d%d", &p[i].x, &p[i].y), p[i].id = i;
    for (i = 0; i < M; ++i)
      scanf("%d%d", &p[N + i].x, &p[N + i].y), p[N + i].id = i,
                                                     p[N + i].deg = deg[i];
    puts("YES");
    solve(p);
  }
  return 0;
}
