#include <bits/stdc++.h>
using namespace std;
const int N = 1e5 + 9;
struct Point {
  double x, y, z;
  int ty;
  Point operator-(const Point& b) const {
    return (Point){x - b.x, y - b.y, z - b.z};
  }
  Point operator+(const Point& b) const {
    return (Point){x + b.x, y + b.y, z + b.z};
  }
  double len() { return sqrt(x * x + y * y + z * z); }
  Point operator*(const double& b) const {
    return (Point){x * b, y * b, z * b};
  }
} pn[N], pm[N], hn, hm, Linep[N * 2];
pair<double, int> num[N * 2];
int n, m, cnt;
double dot(Point a, Point b) { return a.x * b.x + a.y * b.y + a.z * b.z; }
Point cross(Point a, Point b) {
  return (Point){a.y * b.z - a.z * b.y, a.z * b.x - a.x * b.z,
                 a.x * b.y - a.y * b.x};
}
Point LinePlaneIntersection(Point p1, Point p2, Point p0, Point n) {
  Point v = p2 - p1;
  double t = (dot(n, p0 - p1) / dot(n, p2 - p1));
  return p1 + v * t;
}
Point LineCross(Point a, Point b, Point c, Point d) {
  Point n = cross(b - a, d - c);
  n = d + n;
  Point f = cross(d - c, n - c);
  double t = dot(f, c - a) / dot(f, b - a);
  Point res = a + (b - a) * t;
  return res;
}
void solve() {
  cnt = 0;
  for (int i = 1; i <= n; ++i) {
    double nf = dot(hm, pn[i] - pm[1]);
    double nt = dot(hm, pn[i + 1] - pm[1]);
    bool cro = 0;
    if (nf * nt < -1e-8)
      cro = 1;
    else if (nf * nt < 1e-8) {
      if (nf < -1e-8 || nt < -1e-8) cro = 1;
    }
    if (cro) {
      int tp;
      if (nf < -1e-8)
        tp = 1;
      else
        tp = -1;
      Linep[++cnt] = LinePlaneIntersection(pn[i], pn[i + 1], pm[1], hm);
      Linep[cnt].ty = tp;
    }
  }
  if (cnt == 0) {
    puts("NO");
    return;
  }
  Point lv = cross(hn, hm);
  for (int i = 1; i <= m; ++i) {
    Point mf = cross(lv, pm[i] - Linep[1]);
    Point mt = cross(lv, pm[i + 1] - Linep[1]);
    bool cro = 0;
    if (dot(mf, mt) < -1e-8)
      cro = 1;
    else if (dot(mf, mt) < 1e-8) {
      if (dot(hm, mf) > 1e-8 || dot(hm, mt) > 1e-8) cro = 1;
    }
    if (cro) {
      Linep[++cnt] = LineCross(Linep[1], Linep[1] + lv, pm[i], pm[i + 1]);
      Linep[cnt].ty = 0;
    }
  }
  for (int i = 1; i <= cnt; ++i) {
    num[i].first = dot(Linep[i] - Linep[1], lv);
    num[i].second = Linep[i].ty;
  }
  sort(num + 1, num + 1 + cnt);
  int a0 = 0, a1 = 0;
  int now = 0;
  for (int i = cnt; i >= 1; --i) {
    if (num[i].second == 0)
      ++now;
    else if (now & 1) {
      if (num[i].second == 1)
        ++a1;
      else
        ++a0;
    }
  }
  if (a1 == a0)
    puts("NO");
  else
    puts("YES");
}
int main() {
  scanf("%d", &n);
  for (int i = 1; i <= n; ++i) {
    int xx, yy, zz;
    scanf("%d %d %d", &xx, &yy, &zz);
    pn[i].x = xx;
    pn[i].y = yy;
    pn[i].z = zz;
  }
  scanf("%d", &m);
  for (int i = 1; i <= m; ++i) {
    int xx, yy, zz;
    scanf("%d %d %d", &xx, &yy, &zz);
    pm[i].x = xx;
    pm[i].y = yy;
    pm[i].z = zz;
  }
  pn[n + 1] = pn[1];
  pm[m + 1] = pm[1];
  hn = cross(pn[2] - pn[1], pn[3] - pn[1]);
  hm = cross(pm[2] - pm[1], pm[3] - pm[1]);
  Point tem = cross(hn, hm);
  if (tem.len() < 1e-8) {
    puts("NO");
    return 0;
  }
  solve();
}
