#include <bits/stdc++.h>
using namespace std;
int T;
inline int read() {
  int t;
  scanf("%d", &t);
  return t;
}
int H, L;
int a[1010], b[1010];
bitset<500010> A[1010];
int stA_qu[1010], stA_hui[1010];
int totA_qu, totA_hui;
int stB_qu[1010], stB_hui[1010];
int totB_qu, totB_hui;
bool cmp1(int a, int b) { return a < b; }
bool cmp2(int a, int b) { return a > b; }
void out(int a, int b) {
  if (a || b) cout << a << " " << b << '\n';
}
int main() {
  T = read();
  while (T--) {
    int sumA = 0, sumB = 0;
    H = read();
    for (int i = 1; i <= H; i++) a[i] = read(), sumA += a[i];
    L = read();
    for (int i = 1; i <= L; i++) b[i] = read(), sumB += b[i];
    if (sumA % 2 || sumB % 2 || L != H) {
      cout << "NO\n";
      continue;
    }
    sumA >>= 1, sumB >>= 1;
    A[0].reset();
    A[0][0] = 1;
    for (int i = 1; i <= H; i++) A[i] = A[i - 1] | (A[i - 1] << a[i]);
    if (!A[H][sumA]) {
      cout << "NO\n";
      continue;
    }
    totA_qu = totA_hui = 0;
    for (int i = H; i >= 1; i--) {
      if (sumA >= a[i] && A[i - 1][sumA - a[i]])
        stA_qu[++totA_qu] = a[i], sumA -= a[i];
      else
        stA_hui[++totA_hui] = a[i];
    }
    A[0].reset();
    A[0][0] = 1;
    for (int i = 1; i <= L; i++) A[i] = A[i - 1] | (A[i - 1] << b[i]);
    if (!A[L][sumB]) {
      cout << "NO\n";
      continue;
    }
    totB_qu = totB_hui = 0;
    for (int i = L; i >= 1; i--) {
      if (sumB >= b[i] && A[i - 1][sumB - b[i]])
        stB_qu[++totB_qu] = b[i], sumB -= b[i];
      else
        stB_hui[++totB_hui] = b[i];
    }
    bool ty = 0;
    if (totA_qu > totA_hui)
      std::swap(stA_qu, stA_hui), std::swap(totA_qu, totA_hui);
    if (totB_qu > totB_hui)
      std::swap(stB_qu, stB_hui), std::swap(totB_qu, totB_hui);
    sort(stA_qu + 1, stA_qu + 1 + totA_qu, ty ? cmp1 : cmp2);
    sort(stA_hui + 1, stA_hui + 1 + totA_hui, ty ? cmp1 : cmp2);
    sort(stB_qu + 1, stB_qu + 1 + totB_qu, ty ? cmp2 : cmp1);
    sort(stB_hui + 1, stB_hui + 1 + totB_hui, ty ? cmp2 : cmp1);
    int nowx = 0, nowy = 0;
    int Anum = 1, Bnum = 1;
    cout << "YES\n";
    cout << 0 << " " << 0 << '\n';
    while (Anum <= totA_qu + totA_hui && Bnum <= totB_qu + totB_hui) {
      if (!ty) {
        if (Anum <= totA_qu)
          nowx += stA_qu[Anum];
        else
          nowx -= stA_hui[Anum - totA_qu];
        Anum++;
      } else {
        if (Bnum <= totB_hui)
          nowy -= stB_hui[Bnum];
        else
          nowy += stB_qu[Bnum - totB_hui];
        Bnum++;
      }
      ty ^= 1;
      out(nowx, nowy);
    }
  }
  return 0;
}
