#include <bits/stdc++.h>
template <typename T>
inline T read_uint(T &x) {
  x = 0;
  char ch = getchar();
  while (ch < '0' || ch > '9') {
    ch = getchar();
  }
  while (ch >= '0' && ch <= '9') {
    x = x * 10 + ch - '0';
    ch = getchar();
  }
  return x;
}
inline double read_double() {
  int_fast64_t f = 1, x = 0;
  char ch = getchar();
  while (ch < '0' || ch > '9') {
    if (ch == '-') f = -1;
    ch = getchar();
  }
  while (ch >= '0' && ch <= '9') {
    x = x * 10 + ch - '0';
    ch = getchar();
  }
  x = x * f;
  return (double)x;
}
const double EPS = 1e-10;
class Point {
 public:
  Point() = default;
  Point(double x, double y, double z) : x(x), y(y), z(z) {}
  Point(const Point &rhs) {
    x = rhs.x;
    y = rhs.y;
    z = rhs.z;
  }
  Point &operator=(const Point &rhs) {
    if (this == &rhs) return *this;
    x = rhs.x;
    y = rhs.y;
    z = rhs.z;
    return *this;
  }
  double length() const { return sqrt(x * x + y * y + z * z); }
  void normalize() {
    double l = length();
    x /= l;
    y /= l;
    z /= l;
  }
  virtual ~Point() = default;
  Point cross(const Point &rhs) const {
    double new_x = y * rhs.z - z * rhs.y;
    double new_y = z * rhs.x - x * rhs.z;
    double new_z = x * rhs.y - y * rhs.x;
    return Point(new_x, new_y, new_z);
  }
  double dot(const Point &rhs) const {
    return x * rhs.x + y * rhs.y + z * rhs.z;
  }
  Point operator+(const Point &rhs) const {
    double new_x = x + rhs.x;
    double new_y = y + rhs.y;
    double new_z = z + rhs.z;
    return Point(new_x, new_y, new_z);
  }
  Point operator-(const Point &rhs) const {
    double new_x = x - rhs.x;
    double new_y = y - rhs.y;
    double new_z = z - rhs.z;
    return Point(new_x, new_y, new_z);
  }
  Point &operator+=(const Point &rhs) {
    x += rhs.x;
    y += rhs.y;
    z += rhs.z;
    return *this;
  }
  Point &operator-=(const Point &rhs) {
    x -= rhs.x;
    y -= rhs.y;
    z -= rhs.z;
    return *this;
  }
  friend std::ostream &operator<<(std::ostream &os, const Point &p) {
    os << "Point{x=" << p.x << ", y=" << p.y << ", z=" << p.z << "}";
    return os;
  }
  double get_x() const { return x; }
  double get_y() const { return y; }
  double get_z() const { return z; }

 private:
  double x;
  double y;
  double z;
};
class Line {
 public:
  Line(Point begin, Point end) {
    a = end.get_y() - begin.get_y();
    b = begin.get_x() - end.get_x();
    c = -(a * begin.get_x() + b * begin.get_y());
  }
  virtual ~Line() = default;
  double distance(const Point &p) const {
    return a * p.get_x() + b * p.get_y() + c;
  }
  Point intersect(const Line &rhs) const {
    double d = a * rhs.b - b * rhs.a;
    double dx = (-c) * rhs.b - b * (-rhs.c);
    double dy = a * (-rhs.c) - (-c) * rhs.a;
    return Point(dx / d, dy / d, 0);
  }
  double get_a() const { return a; }
  double get_b() const { return b; }
  double get_c() const { return c; }

 private:
  double a;
  double b;
  double c;
};
class Event {
 public:
  Event(const Point &p, int type) : p(p), type(type) {}
  virtual ~Event() = default;
  const Point &get_p() const { return p; }
  int get_type() const { return type; }

 private:
  Point p;
  int type;
};
double dist(const Point &p, const Point &origin, const Point &norm) {
  return (p - origin).dot(norm);
}
Point project(const Point &p, const Point &origin, const Point &v1,
              const Point &v2) {
  Point vec = p - origin;
  return Point(vec.dot(v1), vec.dot(v2), 0);
}
int main(int argc, char *argv[]) {
  using namespace std;
  double xtmp, ytmp, ztmp;
  uint_fast32_t nn;
  read_uint(nn);
  vector<Point> a;
  a.reserve(nn);
  uint_fast32_t i;
  for (i = 0; i < nn; i++) {
    xtmp = read_double();
    ytmp = read_double();
    ztmp = read_double();
    a.push_back(Point(xtmp, ytmp, ztmp));
  }
  uint_fast32_t mm;
  read_uint(mm);
  vector<Point> b;
  b.reserve(nn);
  for (i = 0; i < mm; i++) {
    xtmp = read_double();
    ytmp = read_double();
    ztmp = read_double();
    b.push_back(Point(xtmp, ytmp, ztmp));
  }
  for (i = 1; i < nn; i++) {
    a[i] -= a[0];
  }
  for (i = 0; i < mm; i++) {
    b[i] -= a[0];
  }
  a[0] = Point(0.0, 0.0, 0.0);
  Point v1 = a[nn - 1] - a[0];
  Point v2 = a[1] - a[0];
  Point norm = v1.cross(v2);
  norm.normalize();
  v1.normalize();
  v2 = norm.cross(v1);
  v2.normalize();
  bool same_plane = true;
  for (i = 0; i < mm; i++) {
    double or_dist = (b[i] - a[0]).dot(norm);
    if (abs(or_dist) > EPS) {
      same_plane = false;
    }
  }
  if (same_plane) {
    cout << "NO\n";
    return 0;
  }
  vector<Event> events;
  for (i = 0; i < mm; i++) {
    Point first = b[i];
    Point second = b[(i + 1) % b.size()];
    double dist1 = dist(first, a[0], norm);
    double dist2 = dist(second, a[0], norm);
    bool swap = false;
    if (dist1 > dist2) {
      swap = true;
      double tmp = dist1;
      dist1 = dist2;
      dist2 = tmp;
      Point tmpp = first;
      first = second;
      second = tmpp;
    }
    if (dist1 <= EPS && dist2 > EPS) {
      double ratio = (0 - dist1) / (dist2 - dist1);
      Point inter(first.get_x() * (1 - ratio) + second.get_x() * ratio,
                  first.get_y() * (1 - ratio) + second.get_y() * ratio,
                  first.get_z() * (1 - ratio) + second.get_z() * ratio);
      inter = project(inter, a[0], v1, v2);
      events.push_back(Event(inter, swap ? 1 : -1));
    }
  }
  if (events.size() == 0) {
    cout << "NO\n";
    return 0;
  }
  Line line(events[0].get_p(), events[1].get_p());
  for (i = 1; i < nn; i++) {
    a[i] = project(a[i], a[0], v1, v2);
  }
  a[0] = Point(0, 0, 0);
  for (i = 0; i < nn; i++) {
    Point first = a[i], second = a[(i + 1) % nn];
    double dist1 = line.distance(first);
    double dist2 = line.distance(second);
    if (dist1 > dist2) {
      double tmp = dist1;
      dist1 = dist2;
      dist2 = tmp;
    }
    if (dist1 <= EPS && EPS < dist2) {
      Line second_line(first, second);
      Point inter = line.intersect(second_line);
      events.push_back(Event(inter, 0));
    }
  }
  const Point direction(-line.get_b(), line.get_a(), 0);
  sort(events.begin(), events.end(),
       [direction](const Event &a, const Event &b) -> bool {
         return direction.dot(a.get_p()) < direction.dot(b.get_p());
       });
  int result = 0;
  bool inside = false;
  for (auto &e : events) {
    if (e.get_type() == 0) {
      inside ^= true;
    } else {
      if (inside) {
        result += e.get_type();
      }
    }
  }
  cout << (result == 0 ? "NO\n" : "YES\n");
  return 0;
}
