#include <bits/stdc++.h>
using namespace std;
template <typename T1, typename T2>
inline T1 max(T1 a, T2 b) {
  return a < b ? b : a;
}
template <typename T1, typename T2>
inline T1 min(T1 a, T2 b) {
  return a < b ? a : b;
}
const char lf = '\n';
namespace ae86 {
const int bufl = 1 << 15;
char buf[bufl], *s = buf, *t = buf;
inline int fetch() {
  if (s == t) {
    t = (s = buf) + fread(buf, 1, bufl, stdin);
    if (s == t) return EOF;
  }
  return *s++;
}
inline int ty() {
  int a = 0;
  int b = 1, c = fetch();
  while (!isdigit(c)) b ^= c == '-', c = fetch();
  while (isdigit(c)) a = a * 10 + c - 48, c = fetch();
  return b ? a : -a;
}
}  // namespace ae86
using ae86::ty;
const int _ = 100007, __ = _ << 1;
const char *NO = "NO", *YES = "YES";
inline int sain(long long x) { return x == 0 ? 0 : (x > 0 ? 1 : -1); }
struct points {
  long long x, y, z;
  points(long long x_ = 0, long long y_ = 0, long long z_ = 0) {
    x = x_, y = y_, z = z_;
  }
  friend points operator+(points a, points b) {
    return points(a.x + b.x, a.y + b.y, a.z + b.z);
  }
  friend points operator-(points a, points b) {
    return points(a.x - b.x, a.y - b.y, a.z - b.z);
  }
  friend points operator*(points a, long long b) {
    return points(a.x * b, a.y * b, a.z * b);
  }
  void takein() { x = ty(), y = ty(), z = ty(); }
};
inline points cox(points a, points b) {
  return points(a.y * b.z - b.y * a.z, a.z * b.x - a.x * b.z,
                a.x * b.y - a.y * b.x);
}
inline long long dox(points a, points b) {
  return a.x * b.x + a.y * b.y + a.z * b.z;
}
inline double spdox(points a, points b) {
  return 1.00 * a.x * b.x + 1.00 * a.y * b.y + 1.00 * a.z * b.z;
}
inline long long mox(points a, points b, points c) { return dox(cox(a, b), c); }
inline long long length2(points a) { return dox(a, a); }
inline long long distan2(points a, points b) { return length2(b - a); }
int n[2];
points p[2][_], fa[2];
int dir[_];
int main() {
  ios::sync_with_stdio(0), cout.tie(nullptr);
  for (int i = 0; i < 2; i++) {
    n[i] = ty();
    for (int j = 1; j <= n[i]; j++) p[i][j].takein();
    p[i][0] = p[i][n[i]], p[i][n[i] + 1] = p[i][1];
    fa[i] = cox(p[i][1] - p[i][0], p[i][2] - p[i][0]);
  }
  points hop = cox(fa[0], fa[1]);
  if (dox(hop, hop) == 0) {
    cout << NO << lf;
    return 0;
  }
  vector<pair<double, pair<int, int>>> temp;
  for (int i = 0; i < 2; i++) {
    for (int j = 0; j <= n[i]; j++)
      dir[j] = sain(dox(p[i][j] - p[i ^ 1][0], fa[i ^ 1]));
    for (int j = 1; j <= n[i]; j++) {
      int dlt = dir[j] - dir[j - 1];
      if (dlt == 0) continue;
      double k = spdox(p[i][j - 1] - p[i ^ 1][0], fa[i ^ 1]) /
                 spdox(p[i][j - 1] - p[i][j], fa[i ^ 1]);
      double loc =
          spdox(p[i][j - 1], hop) + spdox(p[i][j] - p[i][j - 1], hop) * k;
      temp.emplace_back(loc, make_pair(i, dlt));
    }
  }
  sort(temp.begin(), temp.end());
  long long sval = 0, sps = 0;
  for (auto i : temp) {
    if (i.second.first)
      sval += sps * i.second.second;
    else
      sps += i.second.second;
  }
  cout << (sval ? YES : NO) << lf;
  return 0;
}
