#include <bits/stdc++.h>
using namespace std;
bool ruk(vector<long long> lst, vector<long long> &used, long long x) {
  long long n = lst.size();
  vector<bitset<1000001>> dp(n + 1);
  dp[0][0] = 1;
  for (long long i = 1; i <= n; i++) {
    dp[i] = dp[i - 1] | (dp[i - 1] << lst[i - 1]);
  }
  if (!dp[n][x]) {
    return false;
  }
  for (long long i = n; i >= 1; i--) {
    if (x >= lst[i - 1] && dp[i - 1][x - lst[i - 1]]) {
      x -= lst[i - 1];
      used[i - 1] = 1;
    }
  }
  return true;
}
signed main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  long long t;
  cin >> t;
  for (long long q = 0; q < t; q++) {
    long long hor, wer;
    cin >> hor;
    vector<long long> verh, prav;
    long long a = 0, b = 0;
    for (long long i = 0; i < hor; i++) {
      long long x;
      cin >> x;
      a += x;
      prav.push_back(x);
    }
    cin >> wer;
    for (long long i = 0; i < wer; i++) {
      long long x;
      cin >> x;
      b += x;
      verh.push_back(x);
    }
    if (hor != wer) {
      cout << "No\n";
      continue;
    }
    vector<long long> used1(hor, 0), used2(wer, 0);
    if (b % 2 != 0 || !ruk(verh, used1, b / 2)) {
      cout << "No\n";
      continue;
    }
    if (a % 2 != 0 || !ruk(prav, used2, a / 2)) {
      cout << "No\n";
      continue;
    }
    vector<long long> l, r, u, d;
    for (long long i = 0; i < used1.size(); i++) {
      if (used1[i]) {
        u.push_back(verh[i]);
      } else {
        d.push_back(verh[i]);
      }
    }
    for (long long i = 0; i < used2.size(); i++) {
      if (used2[i]) {
        l.push_back(prav[i]);
      } else {
        r.push_back(prav[i]);
      }
    }
    if (r.size() > l.size()) swap(l, r);
    if (d.size() > u.size()) swap(d, u);
    sort(r.begin(), r.end());
    reverse(r.begin(), r.end());
    sort(u.begin(), u.end());
    sort(d.begin(), d.end());
    sort(l.begin(), l.end());
    reverse(l.begin(), l.end());
    long long x = 0, y = 0;
    cout << "Yes\n";
    for (long long i = 0; i < r.size(); i++) {
      x += r[i];
      cout << x << " " << y << '\n';
      y += u[i];
      cout << x << " " << y << '\n';
    }
    for (long long i = r.size(); i < u.size(); i++) {
      x -= l[i - r.size()];
      cout << x << " " << y << '\n';
      y += u[i];
      cout << x << " " << y << '\n';
    }
    for (long long i = 0; i < d.size(); i++) {
      x -= l[u.size() - r.size() + i];
      cout << x << " " << y << '\n';
      y -= d[i];
      cout << x << " " << y << '\n';
    }
  }
  return 0;
}
