#include <bits/stdc++.h>
using namespace std;
const int MAXN = 1005;
int h[MAXN], v[MAXN];
struct vec {
  int x, y;
  bool operator<(const vec& other) const { return y * other.x < x * other.y; }
};
bitset<MAXN * MAXN> dph[MAXN + 5];
bitset<MAXN * MAXN> dpv[MAXN + 5];
void solve() {
  int n, sh = 0;
  scanf("%d", &n);
  for (int i = 1; i <= n; ++i) {
    scanf("%d", &h[i]);
    sh += h[i];
  }
  int m, sv = 0;
  scanf("%d", &m);
  for (int i = 1; i <= m; ++i) {
    scanf("%d", &v[i]);
    sv += v[i];
  }
  if (n != m || sh % 2 || sv % 2) {
    printf("NO\n");
    return;
  }
  dph[0][0] = 1;
  for (int i = 1; i <= n; ++i) {
    dph[i].reset();
    dph[i] = (dph[i - 1] | (dph[i - 1] << h[i]));
  }
  if (dph[n][sh / 2] == 0) {
    printf("NO\n");
    return;
  }
  vector<int> h1, h2;
  sh /= 2;
  for (int i = n; i >= 1; --i) {
    if (sh >= h[i] && dph[i - 1][sh - h[i]]) {
      sh -= h[i];
      h1.push_back(h[i]);
    } else {
      h2.push_back(h[i]);
    }
  }
  if (h1.size() > h2.size()) swap(h1, h2);
  dpv[0][0] = 1;
  for (int i = 1; i <= m; ++i) {
    dpv[i].reset();
    dpv[i] = (dpv[i - 1] | (dpv[i - 1] << v[i]));
  }
  if (dpv[m][sv / 2] == 0) {
    printf("NO\n");
    return;
  }
  vector<int> v1, v2;
  sv /= 2;
  for (int i = m; i >= 1; --i) {
    if (sv >= v[i] && dpv[i - 1][sv - v[i]]) {
      sv -= v[i];
      v1.push_back(v[i]);
    } else {
      v2.push_back(v[i]);
    }
  }
  if (v1.size() > v2.size()) swap(v1, v2);
  vector<vec> a, b, c;
  for (int i = 0; i < h1.size(); ++i) a.push_back({h1[i], v2[i]});
  for (int i = h1.size(); i < v2.size(); ++i)
    b.push_back({-h2[i - h1.size()], v2[i]});
  for (int i = v2.size() - h1.size(); i < h2.size(); ++i)
    c.push_back({-h2[i], -v1[i - v2.size() + h1.size()]});
  sort(a.begin(), a.end());
  sort(c.begin(), c.end());
  vector<vec> op;
  for (auto it : a) op.push_back(it);
  for (auto it : b) op.push_back(it);
  for (auto it : c) op.push_back(it);
  printf("YES\n");
  int x = 0, y = 0;
  for (auto it : op) {
    printf("%d %d\n", x, y);
    x += it.x;
    printf("%d %d\n", x, y);
    y += it.y;
  }
}
int main() {
  int t;
  scanf("%d", &t);
  while (t--) solve();
  return 0;
}
