#include <bits/stdc++.h>   using namespace std;   using ll = long long;   const int N = 3005;   const double PI = acos(-1);   struct Point {     ll x, y;   };   inline Point operator+(const Point &a, const Point &b) {     return {a.x + b.x, a.y + b.y};   }   inline Point operator-(const Point &a, const Point &b) {     return {a.x - b.x, a.y - b.y};   }   inline ll cross(const Point &a, const Point &b) {     return a.x * b.y - a.y * b.x;   }   inline double polar(const Point &a) { return atan2(a.y, a.x); }   int n, m, r[N];   Point a[N], b[N];   void solve(vector<int> va, vector<pair<int, int>> vb) {     while (1) {       if (va.size() == 1) {         for (auto &i : vb) cout << i.first <<     << va[0] << endl;         return;       }       if (vb.size() == 1) {         for (auto &i : va) cout << vb[0].first <<     << i << endl;         return;       }       for (int i = 0; i < int(vb.size()); i++)         if (vb[i].second > vb[0].second) swap(vb[i], vb[0]);       vector<pair<double, pair<int, int>>> tmp((va.size() + vb.size()) * 2);       int idx = 0;       for (int i = 0; i < int(va.size()); i++)         tmp[++idx] = {polar(a[va[i]] - b[vb[0].first]), {va[i], 0}};       for (int i = 1; i < int(vb.size()); i++)         tmp[++idx] = {polar(b[vb[i].first] - b[vb[0].first]), vb[i]};       sort(tmp.begin() + 1, tmp.begin() + idx + 1);       for (int i = 1; i <= idx; i++)         tmp[idx + i] = tmp[i], tmp[idx + i].first += 2 * PI;       for (int i = 1, j = 0, sum = 0; i <= idx;            sum -= 1 - tmp[i++].second.second) {         if (sum >= 1 && sum <= vb[0].second - 1) {           vector<int> xa;           vector<pair<int, int>> xb;           xb.push_back({vb[0].first, sum});           vb[0].second -= sum;           vb.resize(1);           va.clear();           for (int k = i; k <= j; k++)             if (!tmp[k].second.second)               xa.push_back(tmp[k].second.first);             else               xb.push_back(tmp[k].second);           for (int k = j + 1; k <= i + idx - 1; k++)             if (!tmp[k].second.second)               va.push_back(tmp[k].second.first);             else               vb.push_back(tmp[k].second);           if (xa.size() + xb.size() > va.size() + vb.size())             swap(xa, va), swap(xb, vb);           solve(xa, xb);           break;         }         while (tmp[j + 1].first - tmp[i].first <= PI)           sum += 1 - tmp[++j].second.second;         if (sum >= 1 && sum <= vb[0].second - 1) {           vector<int> xa;           vector<pair<int, int>> xb;           xb.push_back({vb[0].first, sum});           vb[0].second -= sum;           vb.resize(1);           va.clear();           for (int k = i; k <= j; k++)             if (!tmp[k].second.second)               xa.push_back(tmp[k].second.first);             else               xb.push_back(tmp[k].second);           for (int k = j + 1; k <= i + idx - 1; k++)             if (!tmp[k].second.second)               va.push_back(tmp[k].second.first);             else               vb.push_back(tmp[k].second);           if (xa.size() + xb.size() > va.size() + vb.size())             swap(xa, va), swap(xb, vb);           solve(xa, xb);           break;         }       }     }   }   int main() {     ios::sync_with_stdio(false);     int T;     cin >> T;     while (T--) {       int n, m;       cin >> n >> m;       vector<int> va;       vector<pair<int, int>> vb;       for (int i = 1; i <= m; i++) cin >> r[i];       for (int i = 1; i <= n; i++) cin >> a[i].x >> a[i].y, va.push_back(i);       for (int i = 1; i <= m; i++)         cin >> b[i].x >> b[i].y, vb.push_back({i, r[i]});       cout <<  YES  << endl;       solve(va, vb);     }     return 0;   }