#include <bits/stdc++.h>
using namespace std;
const int N = 1000;
int T, n, m, a[N + 5], b[N + 5], suma, sumb;
int x[2][N + 5], y[2][N + 5], totx[2], toty[2], tot;
bitset<N * N> dp[N + 5];
struct node {
  int x, y;
} ans[N + 5];
int pre();
void solve();
int cmp(int a, int b) { return a > b; }
int main() {
  scanf("%d", &T);
  while (T--) {
    suma = sumb = tot = 0;
    totx[1] = totx[0] = toty[1] = toty[0] = 0;
    scanf("%d", &n);
    for (int i = 1; i <= n; i++) scanf("%d", &a[i]), suma += a[i];
    scanf("%d", &m);
    for (int i = 1; i <= m; i++) scanf("%d", &b[i]), sumb += b[i];
    if (n != m || suma & 1 || sumb & 1) {
      puts("No");
      continue;
    }
    if (!pre()) {
      puts("No");
      continue;
    }
    solve();
    puts("Yes");
    for (int i = 1; i <= tot; i++) printf("%d %d\n", ans[i].x, ans[i].y);
  }
  return 0;
}
void solve() {
  if (totx[1] <= toty[1]) {
    sort(y[1] + 1, y[1] + toty[1] + 1);
    sort(y[0] + 1, y[0] + toty[0] + 1);
    sort(x[1] + 1, x[1] + totx[1] + 1, cmp);
    sort(x[0] + 1, x[0] + totx[0] + 1, cmp);
    node now = {0, 0};
    int i[2] = {1, 1}, j[2] = {1, 1};
    while (n--) {
      if (i[1] <= totx[1])
        now.x += x[1][i[1]++], ans[++tot] = now;
      else
        now.x -= x[0][i[0]++], ans[++tot] = now;
      if (j[1] <= toty[1])
        now.y += y[1][j[1]++], ans[++tot] = now;
      else
        now.y -= y[0][j[0]++], ans[++tot] = now;
    }
  } else {
    sort(x[1] + 1, x[1] + totx[1] + 1);
    sort(x[0] + 1, x[0] + totx[0] + 1);
    sort(y[1] + 1, y[1] + toty[1] + 1, cmp);
    sort(y[0] + 1, y[0] + toty[0] + 1, cmp);
    node now = {0, 0};
    int i[2] = {1, 1}, j[2] = {1, 1};
    while (n--) {
      if (j[1] <= toty[1])
        now.y += y[1][j[1]++], ans[++tot] = now;
      else
        now.y -= y[0][j[0]++], ans[++tot] = now;
      if (i[1] <= totx[1])
        now.x += x[1][i[1]++], ans[++tot] = now;
      else
        now.x -= x[0][i[0]++], ans[++tot] = now;
    }
  }
}
int pre() {
  dp[0][0] = 1;
  int s1 = suma / 2, s2 = sumb / 2;
  for (int i = 1; i <= n; i++) dp[i] = dp[i - 1] | (dp[i - 1] << a[i]);
  if (!dp[n][s1]) return 0;
  for (int i = n; i >= 1; i--)
    if (s1 >= a[i] && dp[i - 1][s1 - a[i]])
      s1 -= a[i], x[1][++totx[1]] = a[i];
    else
      x[0][++totx[0]] = a[i];
  for (int i = 1; i <= m; i++) dp[i] = dp[i - 1] | (dp[i - 1] << b[i]);
  if (!dp[m][s2]) return 0;
  for (int i = m; i >= 1; i--)
    if (s2 >= b[i] && dp[i - 1][s2 - b[i]])
      s2 -= b[i], y[1][++toty[1]] = b[i];
    else
      y[0][++toty[0]] = b[i];
  return 1;
}
