#include <bits/stdc++.h>
using namespace std;
static const int INF = 0x3f3f3f3f;
static const long long INFL = 0x3f3f3f3f3f3f3f3fLL;
template <typename T, typename U>
static void amin(T &x, U y) {
  if (y < x) x = y;
}
template <typename T, typename U>
static void amax(T &x, U y) {
  if (x < y) x = y;
}
struct Vec3 {
  long double p[3];
  Vec3() : p{} {}
  Vec3(long double x, long double y, long double z) : p{x, y, z} {}
  long double operator[](int i) const { return p[i]; }
};
inline Vec3 operator+(Vec3 a, Vec3 b) {
  return Vec3(a[0] + b[0], a[1] + b[1], a[2] + b[2]);
}
inline Vec3 operator-(Vec3 a, Vec3 b) {
  return Vec3(a[0] - b[0], a[1] - b[1], a[2] - b[2]);
}
inline Vec3 operator*(Vec3 a, long double s) {
  return Vec3(a[0] * s, a[1] * s, a[2] * s);
}
inline long double dot(Vec3 a, Vec3 b) {
  return a[0] * b[0] + a[1] * b[1] + a[2] * b[2];
}
inline Vec3 cross(Vec3 a, Vec3 b) {
  return Vec3(a[1] * b[2] - a[2] * b[1], a[2] * b[0] - a[0] * b[2],
              a[0] * b[1] - a[1] * b[0]);
}
inline long double norm(Vec3 a) { return dot(a, a); }
inline long double abs(Vec3 a) { return sqrt(norm(a)); }
inline Vec3 normalize(Vec3 a) { return a * (1 / abs(a)); }
struct Vec2 {
  long double p[2];
  Vec2() : p{} {}
  Vec2(long double x, long double y) : p{x, y} {}
  long double operator[](int i) const { return p[i]; }
};
inline Vec2 operator+(Vec2 a, Vec2 b) { return Vec2(a[0] + b[0], a[1] + b[1]); }
inline Vec2 operator-(Vec2 a, Vec2 b) { return Vec2(a[0] - b[0], a[1] - b[1]); }
inline Vec2 operator*(Vec2 a, long double s) {
  return Vec2(a[0] * s, a[1] * s);
}
inline long double dot(Vec2 a, Vec2 b) { return a[0] * b[0] + a[1] * b[1]; }
inline long double cross(Vec2 a, Vec2 b) { return a[0] * b[1] - a[1] * b[0]; }
inline long double norm(Vec2 a) { return dot(a, a); }
inline long double abs(Vec2 a) { return sqrt(norm(a)); }
inline Vec2 normalize(Vec2 a) { return a * (1 / abs(a)); }
int main() {
  const long double EPS = 1e-9;
  int n;
  while (~scanf("%d", &n)) {
    vector<Vec3> hole(n);
    for (int(i) = 0; (i) < (int)(n); ++(i)) {
      int x;
      int y;
      int z;
      scanf("%d%d%d", &x, &y, &z);
      hole[i] = Vec3(x, y, z);
    }
    int m;
    scanf("%d", &m);
    vector<Vec3> ring(m);
    for (int(i) = 0; (i) < (int)(m); ++(i)) {
      int x;
      int y;
      int z;
      scanf("%d%d%d", &x, &y, &z);
      ring[i] = Vec3(x, y, z);
    }
    Vec3 axisO = hole[0];
    for (auto &v : hole) v = v - axisO;
    for (auto &v : ring) v = v - axisO;
    Vec3 axisX = normalize(hole[1]);
    Vec3 axisZ = normalize(cross(axisX, hole[n - 1]));
    Vec3 axisY = cross(axisZ, axisX);
    vector<pair<Vec2, int>> points;
    for (int(i) = 0; (i) < (int)(m); ++(i)) {
      Vec3 a = ring[i], b = ring[(i + 1) % m];
      long double za = dot(a, axisZ), zb = dot(b, axisZ);
      if ((za >= EPS) != (zb >= EPS)) {
        Vec3 p = a + (b - a) * (abs(za) / (abs(za) + abs(zb)));
        long double x = dot(p, axisX), y = dot(p, axisY);
        points.emplace_back(Vec2(x, y), za >= EPS ? 1 : -1);
      }
    }
    if (points.empty()) {
      puts("NO");
      continue;
    }
    Vec2 origin = points[0].first;
    Vec2 vec(1, 0);
    for (auto p : points)
      if (norm(p.first - origin) > EPS) {
        vec = normalize(p.first - origin);
        break;
      }
    Vec2 vecR(-vec[1], vec[0]);
    vector<pair<long double, int>> events;
    for (auto p : points)
      events.emplace_back(dot(p.first - origin, vec), p.second);
    for (int(i) = 0; (i) < (int)(n); ++(i)) {
      Vec3 a = hole[i];
      Vec2 a2(dot(a, axisX), dot(a, axisY));
      Vec3 b = hole[(i + 1) % n];
      Vec2 b2(dot(b, axisX), dot(b, axisY));
      long double A = dot(a2 - origin, vecR);
      long double B = dot(b2 - origin, vecR);
      if ((A > EPS) != (B > EPS)) {
        Vec2 x = a2 + (b2 - a2) * (abs(A) / (abs(A) + abs(B)));
        events.emplace_back(dot(x - origin, vec), 0);
      }
    }
    sort(events.begin(), events.end());
    int parity = 0, crosses = 0;
    for (auto ev : events) {
      if (ev.second == 0) {
        parity ^= 1;
      } else {
        if (parity == 1) crosses += ev.second;
      }
    }
    puts(crosses != 0 ? "YES" : "NO");
  }
  return 0;
}
