#include <bits/stdc++.h>
using namespace std;
bool divide(vector<long long>& a) {
  long long n = a.size();
  long long sum = 0;
  for (long long i = 0; i < (long long)(n); i++) {
    sum += a[i];
  }
  if (sum % 2) {
    return false;
  }
  sum /= 2;
  vector<long long> p(sum + 1, -2);
  p[0] = -1;
  long long cur_sum = 0;
  for (long long i = 0; i < n; i++) {
    long long mx = min((long long)(p.size()) - a[i], cur_sum + 1);
    for (long long j = mx - 1; j >= 0; j--) {
      if (p[j] != -2 && p[j + a[i]] == -2) {
        p[j + a[i]] = i;
      }
    }
    cur_sum += a[i];
  }
  if (p[sum] == -2) {
    return false;
  }
  while (sum) {
    a[p[sum]] *= -1;
    sum += a[p[sum]];
  }
  return true;
}
inline long long sgn(long long a) { return a < 0 ? -1 : 1; }
bool cmp1(long long a, long long b) {
  if (sgn(a) != sgn(b)) {
    return sgn(a) > sgn(b);
  }
  return abs(a) > abs(b);
}
bool cmp2(long long a, long long b) {
  if (sgn(a) != sgn(b)) {
    return sgn(a) > sgn(b);
  }
  return abs(a) < abs(b);
}
bool cmp3(long long a, long long b) {
  if (sgn(a) != sgn(b)) {
    return sgn(a) < sgn(b);
  }
  return abs(a) > abs(b);
}
bool cmp4(long long a, long long b) {
  if (sgn(a) != sgn(b)) {
    return sgn(a) < sgn(b);
  }
  return abs(a) < abs(b);
}
bool check(vector<long long>& a, vector<long long>& b) {
  long long n = a.size();
  vector<long long> l(500100, -2e18), r(500100, -2e18);
  vector<long long> l2(500100, -2e18), r2(500100, -2e18);
  vector<long long> w(500100, -2e18 + 1e3), v(500100, -2e18 + 1e3);
  vector<bool> we(500100), ve(500100);
  long long x = 250005, y = 250005;
  for (long long i = 0; i < (long long)(n); i++) {
    if (a[i] > 0) {
      we[x] = true;
      for (long long j = 0; j < (long long)(a[i] + 1); j++) {
        w[x] = y;
        x++;
      }
      x--;
      we[x] = true;
    } else {
      ve[x] = true;
      for (long long j = 0; j < (long long)(-a[i] + 1); j++) {
        v[x] = y;
        x--;
      }
      x++;
      ve[x] = true;
    }
    if (l[x] == -2e18) {
      l[x] = y;
    } else {
      l2[x] = y;
    }
    y += b[i];
    if (r[x] == -2e18) {
      r[x] = y;
    } else {
      r2[x] = y;
    }
    if (l[x] > r[x]) {
      swap(l[x], r[x]);
    }
  }
  bool ok = true;
  for (long long i = 0; i < (long long)(l.size()); i++) {
    if (l[i] < w[i] && w[i] < r[i]) {
      ok = false;
    }
    if (l[i] < v[i] && v[i] < r[i]) {
      ok = false;
    }
    if ((l[i] == w[i] || w[i] == r[i]) && !we[i]) {
      ok = false;
    }
    if ((l[i] == v[i] || v[i] == r[i]) && !ve[i]) {
      ok = false;
    }
    if (l2[i] < w[i] && w[i] < r2[i]) {
      ok = false;
    }
    if (l2[i] < v[i] && v[i] < r2[i]) {
      ok = false;
    }
    if ((l2[i] == w[i] || w[i] == r2[i]) && !we[i]) {
      ok = false;
    }
    if ((l2[i] == v[i] || v[i] == r2[i]) && !ve[i]) {
      ok = false;
    }
  }
  if (ok) {
    cout << "Yes" << endl;
    x = y = 0;
    for (long long i = 0; i < (long long)(n); i++) {
      cout << x << " " << y << endl;
      x += a[i];
      cout << x << " " << y << endl;
      y += b[i];
    }
    return true;
  }
  return false;
}
int32_t main() {
  ios_base::sync_with_stdio(0);
  long long t;
  cin >> t;
  while (t--) {
    long long n;
    cin >> n;
    vector<long long> a(n);
    for (long long i = 0; i < (long long)(n); i++) {
      cin >> a[i];
    }
    long long tmp;
    cin >> tmp;
    vector<long long> b(tmp);
    for (long long i = 0; i < (long long)(tmp); i++) {
      cin >> b[i];
    }
    if (n != tmp || !divide(a) || !divide(b)) {
      cout << "No" << endl;
      continue;
    }
    bool ok = false;
    for (long long k = 0; k < (long long)(2); k++) {
      for (long long i = 0; i < (long long)(4); i++) {
        if (i == 0) {
          sort(a.begin(), a.end(), cmp4);
        } else if (i == 1) {
          sort(a.begin(), a.end(), cmp1);
        } else if (i == 2) {
          sort(a.begin(), a.end(), cmp2);
        } else {
          sort(a.begin(), a.end(), cmp3);
        }
        for (long long j = 0; j < (long long)(4); j++) {
          if (j == 0) {
            sort(b.begin(), b.end(), cmp4);
          } else if (j == 1) {
            sort(b.begin(), b.end(), cmp1);
          } else if (j == 2) {
            sort(b.begin(), b.end(), cmp2);
          } else {
            sort(b.begin(), b.end(), cmp3);
          }
          if (check(a, b)) {
            ok = true;
            break;
          }
        }
        if (ok) {
          break;
        }
      }
      if (ok) {
        break;
      }
      for (long long i = 0; i < (long long)(n); i++) {
        a[i] *= -1;
      }
    }
    if (!ok) {
      cout << "No" << endl;
      continue;
    }
  }
}
