#include <bits/stdc++.h>
using namespace std;
tuple<double, double> simultaneous_equation(double a, double b, double c,
                                            double d, double u, double v) {
  return make_tuple((u * d - b * v) / (a * d - b * c),
                    (a * v - u * c) / (a * d - b * c));
}
tuple<double, double, double> cross_product(double x1, double y1, double z1,
                                            double x2, double y2, double z2) {
  return make_tuple(y1 * z2 - y2 * z1, z1 * x2 - z2 * x1, x1 * y2 - x2 * y1);
}
double dot_product(double x1, double y1, double z1, double x2, double y2,
                   double z2) {
  return x1 * x2 + y1 * y2 + z1 * z2;
}
int main(int argc, char const *argv[]) {
  int n, m;
  scanf("%d", &n);
  double x1[n], y1[n], z1[n];
  tuple<double, double, double> normal1;
  for (int i = 0; i < n; i++) {
    scanf("%lf %lf %lf", &x1[i], &y1[i], &z1[i]);
    if (i == 2) {
      normal1 = cross_product(x1[1] - x1[0], y1[1] - y1[0], z1[1] - z1[0],
                              x1[2] - x1[1], y1[2] - y1[1], z1[2] - z1[1]);
    }
  }
  scanf("%d", &m);
  double x2[m], y2[m], z2[m];
  tuple<double, double, double> normal2;
  for (int i = 0; i < m; i++) {
    scanf("%lf %lf %lf", &x2[i], &y2[i], &z2[i]);
    if (i == 2) {
      normal2 = cross_product(x2[1] - x2[0], y2[1] - y2[0], z2[1] - z2[0],
                              x2[2] - x2[1], y2[2] - y2[1], z2[2] - z2[1]);
    }
  }
  tuple<double, double, double> intersection_vector =
      cross_product(get<0>(normal1), get<1>(normal1), get<2>(normal1),
                    get<0>(normal2), get<1>(normal2), get<2>(normal2));
  double a1 = get<0>(normal1);
  double b1 = get<1>(normal1);
  double c1 = get<2>(normal1);
  double d1 = -(get<0>(normal1) * x1[0] + get<1>(normal1) * y1[0] +
                get<2>(normal1) * z1[0]);
  double a2 = get<0>(normal2);
  double b2 = get<1>(normal2);
  double c2 = get<2>(normal2);
  double d2 = -(get<0>(normal2) * x2[0] + get<1>(normal2) * y2[0] +
                get<2>(normal2) * z2[0]);
  double intersection_x;
  double intersection_y;
  double intersection_z;
  double max = 0;
  if (abs(get<0>(intersection_vector)) > max) {
    max = abs(get<0>(intersection_vector));
    intersection_x = 0;
    intersection_y = (c1 * d2 - c2 * d1) / (b1 * c2 - b2 * c1);
    intersection_z = (b2 * d1 - b1 * d2) / (b1 * c2 - b2 * c1);
  }
  if (abs(get<1>(intersection_vector)) > max) {
    max = abs(get<1>(intersection_vector));
    intersection_x = (c1 * d2 - c2 * d1) / (a1 * c2 - a2 * c1);
    intersection_y = 0;
    intersection_z = (a2 * d1 - a1 * d2) / (a1 * c2 - a2 * c1);
  }
  if (abs(get<2>(intersection_vector)) > max) {
    max = abs(get<2>(intersection_vector));
    intersection_x = (b1 * d2 - b2 * d1) / (a1 * b2 - a2 * b1);
    intersection_y = (a2 * d1 - a1 * d2) / (a1 * b2 - a2 * b1);
    intersection_z = 0;
  }
  tuple<double, double, double> intersection_normal_1 =
      cross_product(get<0>(normal1), get<1>(normal1), get<2>(normal1),
                    get<0>(intersection_vector), get<1>(intersection_vector),
                    get<2>(intersection_vector));
  tuple<double, double, double> intersection_normal_2 =
      cross_product(get<0>(normal2), get<1>(normal2), get<2>(normal2),
                    get<0>(intersection_vector), get<1>(intersection_vector),
                    get<2>(intersection_vector));
  int sign1[n];
  for (int i = 0; i < n; i++) {
    if (dot_product(x1[i] - intersection_x, y1[i] - intersection_y,
                    z1[i] - intersection_z, get<0>(intersection_normal_1),
                    get<1>(intersection_normal_1),
                    get<2>(intersection_normal_1)) > 0) {
      sign1[i] = 1;
    } else if (dot_product(x1[i] - intersection_x, y1[i] - intersection_y,
                           z1[i] - intersection_z,
                           get<0>(intersection_normal_1),
                           get<1>(intersection_normal_1),
                           get<2>(intersection_normal_1)) < 0) {
      sign1[i] = -1;
    } else {
      sign1[i] = 0;
    }
  }
  int sign2[m];
  for (int i = 0; i < m; i++) {
    if (dot_product(x2[i] - intersection_x, y2[i] - intersection_y,
                    z2[i] - intersection_z, get<0>(intersection_normal_2),
                    get<1>(intersection_normal_2),
                    get<2>(intersection_normal_2)) > 0) {
      sign2[i] = 1;
    } else if (dot_product(x2[i] - intersection_x, y2[i] - intersection_y,
                           z2[i] - intersection_z,
                           get<0>(intersection_normal_2),
                           get<1>(intersection_normal_2),
                           get<2>(intersection_normal_2)) < 0) {
      sign2[i] = -1;
    } else {
      sign2[i] = 0;
    }
  }
  vector<pair<double, int>> intersection_list_1;
  for (int i = 0; i < n; i++) {
    int previous_i = i - 1;
    int current_i = i;
    int next_i = i + 1;
    int next_next_i = i + 2;
    if (i == 0) {
      previous_i = n - 1;
    } else if (i == n - 1) {
      next_i = 0;
      next_next_i = 1;
    } else if (i == n - 2) {
      next_next_i = 0;
    }
    if (sign1[current_i] * sign1[next_i] == -1) {
      double multiplier;
      if (!isnan(get<1>(simultaneous_equation(
              x1[current_i] - x1[next_i], -get<0>(intersection_vector),
              y1[current_i] - y1[next_i], -get<1>(intersection_vector),
              intersection_x - x1[current_i],
              intersection_y - y1[current_i])))) {
        multiplier = get<1>(simultaneous_equation(
            x1[current_i] - x1[next_i], -get<0>(intersection_vector),
            y1[current_i] - y1[next_i], -get<1>(intersection_vector),
            intersection_x - x1[current_i], intersection_y - y1[current_i]));
      } else if (!isnan(get<1>(simultaneous_equation(
                     y1[current_i] - y1[next_i], -get<1>(intersection_vector),
                     z1[current_i] - z1[next_i], -get<2>(intersection_vector),
                     intersection_y - y1[current_i],
                     intersection_z - z1[current_i])))) {
        multiplier = get<1>(simultaneous_equation(
            y1[current_i] - y1[next_i], -get<1>(intersection_vector),
            z1[current_i] - z1[next_i], -get<2>(intersection_vector),
            intersection_y - y1[current_i], intersection_z - z1[current_i]));
      } else if (!isnan(get<1>(simultaneous_equation(
                     z1[current_i] - z1[next_i], -get<2>(intersection_vector),
                     x1[current_i] - x1[next_i], -get<0>(intersection_vector),
                     intersection_z - z1[current_i],
                     intersection_x - x1[current_i])))) {
        multiplier = get<1>(simultaneous_equation(
            z1[current_i] - z1[next_i], -get<2>(intersection_vector),
            x1[current_i] - x1[next_i], -get<0>(intersection_vector),
            intersection_z - z1[current_i], intersection_x - x1[current_i]));
      }
      intersection_list_1.push_back(pair<double, int>(
          dot_product(get<0>(intersection_vector) * multiplier + intersection_x,
                      get<1>(intersection_vector) * multiplier + intersection_y,
                      get<2>(intersection_vector) * multiplier + intersection_z,
                      get<0>(intersection_vector), get<1>(intersection_vector),
                      get<2>(intersection_vector)),
          1));
    } else if ((sign1[current_i] == 0 &&
                sign1[previous_i] * sign1[next_i] == -1) ||
               (n >= 4 && sign1[current_i] == 0 && sign1[next_i] == 0 &&
                sign1[previous_i] * sign1[next_next_i] == -1)) {
      intersection_list_1.push_back(pair<double, int>(
          dot_product(x1[current_i], y1[current_i], z1[current_i],
                      get<0>(intersection_vector), get<1>(intersection_vector),
                      get<2>(intersection_vector)),
          1));
    }
  }
  vector<pair<double, int>> intersection_list_2;
  for (int i = 0; i < m; i++) {
    int previous_i = i - 1;
    int current_i = i;
    int next_i = i + 1;
    int next_next_i = i + 2;
    if (i == 0) {
      previous_i = m - 1;
    } else if (i == m - 1) {
      next_i = 0;
      next_next_i = 1;
    } else if (i == m - 2) {
      next_next_i = 0;
    }
    if (sign2[current_i] * sign2[next_i] == -1) {
      double multiplier;
      if (!isnan(get<1>(simultaneous_equation(
              x2[current_i] - x2[next_i], -get<0>(intersection_vector),
              y2[current_i] - y2[next_i], -get<1>(intersection_vector),
              intersection_x - x2[current_i],
              intersection_y - y2[current_i])))) {
        multiplier = get<1>(simultaneous_equation(
            x2[current_i] - x2[next_i], -get<0>(intersection_vector),
            y2[current_i] - y2[next_i], -get<1>(intersection_vector),
            intersection_x - x2[current_i], intersection_y - y2[current_i]));
      } else if (!isnan(get<1>(simultaneous_equation(
                     y2[current_i] - y2[next_i], -get<1>(intersection_vector),
                     z2[current_i] - z2[next_i], -get<2>(intersection_vector),
                     intersection_y - y2[current_i],
                     intersection_z - z2[current_i])))) {
        multiplier = get<1>(simultaneous_equation(
            y2[current_i] - y2[next_i], -get<1>(intersection_vector),
            z2[current_i] - z2[next_i], -get<2>(intersection_vector),
            intersection_y - y2[current_i], intersection_z - z2[current_i]));
      } else if (!isnan(get<1>(simultaneous_equation(
                     z2[current_i] - z2[next_i], -get<2>(intersection_vector),
                     x2[current_i] - x2[next_i], -get<0>(intersection_vector),
                     intersection_z - z2[current_i],
                     intersection_x - x2[current_i])))) {
        multiplier = get<1>(simultaneous_equation(
            z2[current_i] - z2[next_i], -get<2>(intersection_vector),
            x2[current_i] - x2[next_i], -get<0>(intersection_vector),
            intersection_z - z2[current_i], intersection_x - x2[current_i]));
      }
      intersection_list_2.push_back(pair<double, int>(
          dot_product(get<0>(intersection_vector) * multiplier + intersection_x,
                      get<1>(intersection_vector) * multiplier + intersection_y,
                      get<2>(intersection_vector) * multiplier + intersection_z,
                      get<0>(intersection_vector), get<1>(intersection_vector),
                      get<2>(intersection_vector)),
          2));
    } else if ((sign2[current_i] == 0 &&
                sign2[previous_i] * sign2[next_i] == -1) ||
               (m >= 4 && sign2[current_i] == 0 && sign2[next_i] == 0 &&
                sign2[previous_i] * sign2[next_next_i] == -1)) {
      intersection_list_2.push_back(pair<double, int>(
          dot_product(x2[current_i], y2[current_i], z2[current_i],
                      get<0>(intersection_vector), get<1>(intersection_vector),
                      get<2>(intersection_vector)),
          2));
    }
  }
  intersection_list_1.insert(intersection_list_1.end(),
                             intersection_list_2.begin(),
                             intersection_list_2.end());
  sort(intersection_list_1.begin(), intersection_list_1.end());
  vector<int> result_list;
  while (!intersection_list_1.empty()) {
    if (result_list.empty() ||
        (!result_list.empty() &&
         intersection_list_1.back().second != result_list.back())) {
      result_list.push_back(intersection_list_1.back().second);
    } else if (!result_list.empty() &&
               intersection_list_1.back().second == result_list.back()) {
      result_list.pop_back();
    }
    intersection_list_1.pop_back();
  }
  if (result_list.empty()) {
    cout << "NO" << endl;
  } else {
    cout << "YES" << endl;
  }
  return 0;
}
