#include <bits/stdc++.h>
using namespace std;
const int MAX = 501;
const int MAXS = MAX * 1000;
bitset<MAXS> dp[MAX];
int n[2];
int a[2][MAX];
bool b[2][MAX];
bool calcDP(int idx) {
  dp[0][0] = true;
  int s = 0;
  for (int i = (0); i < (n[idx]); ++i) {
    dp[i + 1] = dp[i] | (dp[i] << a[idx][i]);
    s += a[idx][i];
  }
  if ((s & 1) || !dp[n[idx]][s >> 1]) return false;
  s >>= 1;
  for (int i = (n[idx]) - 1; i >= (0); --i) {
    if (s >= a[idx][i] && dp[i][s - a[idx][i]]) {
      s -= a[idx][i];
      b[idx][i] = true;
    } else {
      b[idx][i] = false;
    }
  }
  return true;
}
int main() {
  ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
  int t;
  cin >> t;
  while (t--) {
    for (int it = (0); it < (2); ++it) {
      cin >> n[it];
      for (int i = (0); i < (n[it]); ++i) cin >> a[it][min(i, MAX - 1)];
    }
    if (n[0] != n[1] || !calcDP(0) || !calcDP(1)) {
      cout << "No\n";
      continue;
    }
    for (int it = (0); it < (2); ++it) {
      int cntP = 0;
      for (int i = (0); i < (n[it]); ++i)
        if (b[it][i])
          a[it][i] *= -1;
        else
          cntP++;
      if ((2 * cntP > n[0]) ^ it)
        for (int i = (0); i < (n[0]); ++i) a[it][i] *= -1;
      sort(a[it], a[it] + n[it], [=](int x, int y) {
        return x == y ? false : x * y < 0 ? x > y : ((abs(x) > abs(y)) ^ it);
      });
    }
    cout << "Yes\n";
    int x[2] = {0, 0};
    for (int i = (0); i < (2 * n[0]); ++i) {
      x[i & 1] += a[i & 1][i >> 1];
      for (int j = (0); j < (2); ++j) {
        cout << x[j] << " ";
      }
      cout << "\n";
    }
    for (int j = (0); j < (2); ++j) assert(x[j] == 0);
  }
  return 0;
}
