import java.io.PrintStream;

import java.util.Scanner;

public class MyClass {

    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        PrintStream printer = (System.out);

        int n = scanner.nextInt();
        int b= scanner.nextInt();
        int d= scanner.nextInt();
        scanner.nextLine();
        int count=0;

        String[] oranges= new String[n];
        int total=0;

        for( int i=0; i<n; i++){
            int v=scanner.nextInt();
            oranges[i]=String.valueOf(v);
            total+=v;

        }
        while (true){
            if(total>d){
                count++;
                total-=d;
            }else {
                break;
            }
        }

        printer.print(count);

    }}


import java.io.PrintStream;

import java.util.Scanner;

public class MyClass {

    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        PrintStream printer = (System.out);

        int n = scanner.nextInt();
        int b= scanner.nextInt();
        int d= scanner.nextInt();
        scanner.nextLine();
        int count=0;

        String[] oranges= new String[n];
        float total=0;

        for( int i=0; i<n; i++){
            int v=scanner.nextInt();
            if(v>b){
                v=0;
            }
            oranges[i]=String.valueOf(v);
            total+=v;

        }
        while (true){
            if(total>=d){
                count++;
                total-=d;
            }else {
                break;
            }
        }

        printer.print(count);

    }}


import java.io.PrintStream;

import java.util.Scanner;

public class MyClass {

    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        PrintStream printer = (System.out);

        int n = scanner.nextInt();
        int b= scanner.nextInt();
        int d= scanner.nextInt();
        scanner.nextLine();
        int count=0;

        String[] oranges= new String[n];
        float total=0;

        for( int i=0; i<n; i++){
            int v=scanner.nextInt();
            if(v>b){
                v=b;
            }
            oranges[i]=String.valueOf(v);
            total+=v;

        }
        while (true){
            if(total>d){
                count++;
                total-=d;
            }else {
                break;
            }
        }

        printer.print(count);

    }}


import java.io.PrintStream;

import java.util.Scanner;

public class MyClass {

    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        PrintStream printer = (System.out);

        int n = scanner.nextInt();
        int b= scanner.nextInt();
        int d= scanner.nextInt();
        scanner.nextLine();
        double count=0;

        String[] oranges= new String[n];
        double total=0;

        for( int i=0; i<n; i++){
            int v=scanner.nextInt();
            oranges[i]=String.valueOf(v);
            total+=v;

        }
        while (true){
            if(total>d){
                count++;
                total-=d;
            }else {
                break;
            }
        }

        printer.print(count);

    }}


import java.io.PrintStream;

import java.util.Scanner;

public class MyClass {

    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        PrintStream printer = (System.out);

        int n = scanner.nextInt();
        int b= scanner.nextInt();
        int d= scanner.nextInt();
        scanner.nextLine();

        String[] oranges= new String[n];
        int total=0;

        for( int i=0; i<n; i++){
            int v=scanner.nextInt();
            oranges[i]=String.valueOf(v);
            total+=v;

        }
        int x=total/d;
        if(total==1){
            x--;
        }
        printer.print(x);

    }}


import java.io.PrintStream;

import java.util.Scanner;

public class MyClass {

    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        PrintStream printer = (System.out);

        int n = scanner.nextInt();
        int b= scanner.nextInt();
        int d= scanner.nextInt();
        scanner.nextLine();
        int count=0;

        String[] oranges= new String[n];
        float total=0;

        for( int i=0; i<n; i++){
            int v=scanner.nextInt();
            if(v>b){
                v=0;
            }
          //  oranges[i]=String.valueOf(v);
            total+=v;
            if(total>d){
                count++;
                total=0;
            }

        }

        printer.print(count);

    }}


import java.io.PrintStream;

import java.util.Scanner;

public class MyClass {

    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        PrintStream printer = (System.out);

        int n = scanner.nextInt();
        int b= scanner.nextInt();
        int d= scanner.nextInt();
        scanner.nextLine();
        int count=0;

        String[] oranges= new String[n];
        float total=0;

        for( int i=0; i<n; i++){
            int v=scanner.nextInt();
            oranges[i]=String.valueOf(v);
            total+=v;

        }
        while (true){
            if(total>d){
                count++;
                total-=d;
            }else {
                break;
            }
        }

        printer.print(count);

    }}


import java.io.PrintStream;

import java.util.Scanner;

public class MyClass {

    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        PrintStream printer = (System.out);

        int n = scanner.nextInt();
        int b= scanner.nextInt();
        int d= scanner.nextInt();
        scanner.nextLine();
        int count=0;

        String[] oranges= new String[n];
        double total=0;

        for( int i=0; i<n; i++){
            int v=scanner.nextInt();
            oranges[i]=String.valueOf(v);
            total+=v;

        }
        while (true){
            if(total>d){
                count++;
                total-=d;
            }else {
                break;
            }
        }

        printer.print(count);

    }}


import java.util.Scanner;

/**
 *
 * @author ASUS
 */
public class Juicer {

    /**
     * @param args the command line arguments
     */
    public static void main(String[] args) {
        // TODO code application logic here
        Scanner in=new Scanner(System.in);
        int n=in.nextInt();
        int b=in.nextInt();
        int d=in.nextInt();
        long  t=0;
        int r=0;
        for(int i=0;i<n;i++)
        {
            int a[]=new int[n];
            t+=a[i]=in.nextInt();
            if(a[i]>b)
            {
                t-=a[i];
            }
            if(t>d)
            {
                t=0;
                r++;
            }
        }
        System.out.println(r);
    }

}


/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
package juicer;

import java.util.Scanner;

/**
 *
 * @author ASUS
 */
public class Juicer {

    /**
     * @param args the command line arguments
     */
    public static void main(String[] args) {
        // TODO code application logic here
        Scanner in=new Scanner(System.in);
        int n=in.nextInt();
        int b=in.nextInt();
        int d=in.nextInt();
        int  t=0;
        int r=0;
        for(int i=0;i<n;i++)
        {
            int a[]=new int[n];
            t+=a[i]=in.nextInt();
            if(a[i]>b)
            {
                t-=a[i];
            }
            if(t>d)
            {
                t=0;
                r++;
            }
        }
        System.out.println(r);
    }

}


import java.util.Scanner;

/**
 *
 * @author ASUS
 */
public class Juicer {

    /**
     * @param args the command line arguments
     */
    public static void main(String[] args) {
        // TODO code application logic here
        Scanner in=new Scanner(System.in);
        int n=in.nextInt();
        int b=in.nextInt();
        int d=in.nextInt();
        long t=0;
        long r=0;
        for(int i=0;i<n;i++)
        {
            int a;
            t+=a=in.nextInt();
            if(a>b)
            {
                t-=a;
            }
            if(t>=d)
            {
                t=0;
                r++;
            }
        }
        System.out.println(r);
    }

}


import java.util.Scanner;

/**
 *
 * @author ASUS
 */
public class Juicer {

    /**
     * @param args the command line arguments
     */
    public static void main(String[] args) {
        // TODO code application logic here
        Scanner in=new Scanner(System.in);
        int n=in.nextInt();
        int b=in.nextInt();
        int d=in.nextInt();
        long t=0;
        int r=0;
        for(int i=0;i<n;i++)
        {
            int a[]=new int[n];
            t+=a[i]=in.nextInt();
            if(a[i]>b)
            {
                t-=a[i];
            }
            if(t>d)
            {
                t=0;
                r++;
            }
        }
        System.out.println(r);
    }

}


import java.util.Scanner;

/**
 *
 * @author ASUS
 */
public class Juicer {

    /**
     * @param args the command line arguments
     */
    public static void main(String[] args) {
        // TODO code application logic here
        Scanner in=new Scanner(System.in);
        int n=in.nextInt();
        int b=in.nextInt();
        int d=in.nextInt();
        long t=0;
        long r=0;
        for(int i=0;i<n;i++)
        {
            int a;
            t+=a=in.nextInt();
            if(a>b)
            {
                t-=a;
            }
            if(t>d)
            {
                t=0;
                r++;
            }
        }
        System.out.println(r);
    }

}


import java.util.Scanner;

public class Main {
    public static void main(String[] args){

        Scanner sc=new Scanner(System.in);

        int n= sc.nextInt();
        int b= sc.nextInt();
        int d= sc.nextInt();

        int count=0;
        int res =0;
        for(int i=0;i<n;i++){
            int a= sc.nextInt();
            if(a>b){
                continue;
            }else{
                count+=a;
                if(count>d){
                    res ++;
                    count = 0;
                }
            }

        }

        System.out.println(res);
    }
}


import java.util.Scanner;

public class Main {
    public static void main(String[] args){

        Scanner sc=new Scanner(System.in);

        int n= sc.nextInt();
        int b= sc.nextInt();
        int d= sc.nextInt();

        long count=0;

        for(int i=0;i<n;i++){
            int a= sc.nextInt();
            count+= a<b?a:0;
        }
        System.out.println(count/d);
    }
}


import java.util.Scanner;

public class Main {
    public static void main(String[] args){

        Scanner sc=new Scanner(System.in);

        int n= sc.nextInt();
        int b= sc.nextInt();
        int d= sc.nextInt();

        int count=0;
        int res =0;
        for(int i=0;i<n;i++){
            int a= sc.nextInt();
            count+= a<=b?a:0;
            if(count>d){
                res += count /d;
                count = 0;
            }
        }

        System.out.println(res);
    }
}


import java.util.Scanner;

public class Main {
    public static void main(String[] args){

        Scanner sc=new Scanner(System.in);

        int n= sc.nextInt();
        int b= sc.nextInt();
        int d= sc.nextInt();

        int count=0;

        for(int i=0;i<n;i++){
            int a= sc.nextInt();
            count+= a<b?a:0;
        }
        System.out.println(count/d);
    }
}


import java.util.Scanner;

public class Main {
    public static void main(String[] args){

        Scanner sc=new Scanner(System.in);

        int n= sc.nextInt();
        int b= sc.nextInt();
        int d= sc.nextInt();

        int count=0;
        int res =0;
        for(int i=0;i<n;i++){
            int a= sc.nextInt();
            count+= a<b?a:0;
            if(count>d){
                res += count /d;
                count = count%d;
            }
        }
        res += count /d;
        System.out.println(res);
    }
}


import java.util.Scanner;

public class Main {
    public static void main(String[] args){

        Scanner sc=new Scanner(System.in);

        int n= sc.nextInt();
        int b= sc.nextInt();
        int d= sc.nextInt();

        int count=0;
        int res =0;
        for(int i=0;i<n;i++){
            int a= sc.nextInt();
            count+= a<=b?a:0;
            if(count>d){
                res += count /d;
                count = 0;
            }
        }
        res += count /d;
        System.out.println(res);
    }
}


import java.util.Scanner;

public class Main {
    public static void main(String[] args){

        Scanner sc=new Scanner(System.in);

        int n= sc.nextInt();
        int b= sc.nextInt();
        int d= sc.nextInt();

        int count=0;
        int res =0;
        for(int i=0;i<n;i++){
            int a= sc.nextInt();
            count+= a<b?a:0;
            if(count>d){
                res += count /d;
                count = 0;
            }
        }
        res += count /d;
        System.out.println(res);
    }
}


/*
ID: aaron.c2
LANG: JAVA
TASK: Juicer
*/

import java.io.*;
import java.util.*;

public class Juicer {
    public static void main(String[] args) throws IOException {
        Scanner scan = new Scanner(System.in);

        int n = scan.nextInt();
        int b = scan.nextInt();
        int d = scan.nextInt();
        int waste = 0;
        int count = 0;

        while(n-- > 0) {
            int curOrange = scan.nextInt();
            if(curOrange <= b) {
                waste += b;
            }

            if(waste > d) {
                count++;
                waste = 0;
            }
        }
        if(waste > d) {
            count++;
            waste = 0;
        }
        System.out.println(count);

    }

}


/*
ID: aaron.c2
LANG: JAVA
TASK: Juicer
*/

import java.io.*;
import java.util.*;

public class Juicer {
    public static void main(String[] args) throws IOException {
        Scanner scan = new Scanner(System.in);

        int n = scan.nextInt();
        int b = scan.nextInt();
        int d = scan.nextInt();
        int waste = 0;
        int count = 0;

        for(int i=0;i<n;i++) {
            int curOrange = scan.nextInt();
            if (curOrange <= b) {
                waste += b;

                if (waste > d) {
                    count++;
                    waste = 0;
                }
            }
            System.out.println(curOrange);
        }
        System.out.println(count);

    }

}


import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        int n=in.nextInt(),b=in.nextInt(),d=in.nextInt();
        int sum=0,c=0;
        for(int i=0;i<n;i++)
        {
            int a=in.nextInt();
            if(a>b)
                continue;
            else
            {
                sum+=a;
                if(sum>d)
                {
                    ++c;
                    sum=0;
                }
            }
        }
        System.out.println(c);

    }

}


/*
ID: aaron.c2
LANG: JAVA
TASK: Juicer
*/

import java.io.*;
import java.util.*;

public class Juicer {
    public static void main(String[] args) throws IOException {
        Scanner scan = new Scanner(System.in);

        int n = scan.nextInt();
        int b = scan.nextInt();
        int d = scan.nextInt();
        int waste = 0;
        int count = 0;

        for(int i=0;i<n;i++) {
            int curOrange = scan.nextInt();
            if (curOrange <= b) {
                waste += b;

                if (waste > d) {
                    count++;
                    waste = 0;
                }
            }
        }
        System.out.println(count);

    }

}


/*
ID: aaron.c2
LANG: JAVA
TASK: Juicer
*/

import java.io.*;
import java.util.*;

public class Juicer {
    public static void main(String[] args) throws IOException {
        Scanner scan = new Scanner(System.in);

        int n = scan.nextInt();
        int b = scan.nextInt();
        int d = scan.nextInt();
        int waste = 0;
        int count = 0;

        while(n-- > 0) {
            int curOrange = scan.nextInt();
            if(curOrange <= b) {
                waste += b;
            }

            if(waste > d) {
                count++;
                waste = 0;
            }
        }
        System.out.println(count);

    }

}


/*
ID: aaron.c2
LANG: JAVA
TASK: Juicer
*/

import java.io.*;
import java.util.*;

public class Juicer {
    public static void main(String[] args) throws IOException {
        Scanner scan = new Scanner(System.in);

        int n = scan.nextInt();
        int b = scan.nextInt();
        int d = scan.nextInt();
        int waste = 0;
        int count = 0;

        while(n-- > 0) {
            int curOrange = scan.nextInt();
            if (curOrange <= b) {
                waste += b;

                if (waste > d) {
                    count++;
                    waste = 0;
                }
            }

        }
        System.out.println(count);

    }

}


import java.util.Scanner;

/**
 *
 * @author ONE BY ONE
 */
public class AJuicer {

    /**
     * @param args the command line arguments
     */
    public static void main(String[] args) {
      Scanner x= new Scanner(System.in);
      int a=x.nextInt();
    int b=x.nextInt();
    int d=x.nextInt(); int y;int m=0;int u=0;int n=0;
    for(int i=0;i<a;i++){
        y=x.nextInt();
    if(y<=b ){
        m+=y;u=1;
    }
    if(y>b)
        continue;

   if(m>d){
       m=m-d;
   n++;}}
    if(u==1)

        System.out.println(n);
else
            System.out.println(0);

    }

}


from math import gcd, sqrt
from functools import reduce
import sys

input = sys.stdin.readline

EPS = 0.000000001

def inp():
    return(int(input()))

def inlt():
    return(list(map(int,input().split())))

def GCD(args):
    return reduce(gcd, args)

def plane_value(plane, point):
    A, B, C, D = plane
    x, y, z = point
    return A*x + B*y + C*z + D

def plane(p1, p2, p3):
    x1, y1, z1 = p1
    x2, y2, z2 = p2
    x3, y3, z3 = p3
    a1, b1, c1 = x2 - x1, y2 - y1, z2 - z1
    a2, b2, c2 = x3 - x1, y3 - y1, z3 - z1
    a, b, c = b1 * c2 - b2 * c1, a2 * c1 - a1 * c2, a1 * b2 - b1 * a2
    d = (- a * x1 - b * y1 - c * z1)
    g = GCD([a,b,c,d])
    return a//g, b//g, c//g, d//g

def cross(a, b):
    return (a[1]*b[2]-a[2]*b[1], a[2]*b[0]-a[0]*b[2], a[0]*b[1]-a[1]*b[0])

def intersection_of_two_planes(p1, p2):
    A1, B1, C1, D1 = p1
    A2, B2, C2, D2 = p2

    crossprod = cross([A1,B1,C1],[A2,B2,C2])

    if (A1*B2-A2*B1) != 0:
        x = ((B1*D2-B2*D1)/(A1*B2-A2*B1), crossprod[0])
        y = ((A2*D1-A1*D2)/(A1*B2-A2*B1), crossprod[1])
        z = (0,crossprod[2])
    elif (B1*C2-B2*C1) != 0:
        x = (0,crossprod[0])
        y = ((C1*D2-C2*D1)/(B1*C2-B2*C1), crossprod[1])
        z = ((B2*D1-B1*D2)/(B1*C2-B2*C1), crossprod[2])
    elif (A1*C2-A2*C1) != 0:
        x = ((C1*D2-C2*D1)/(A1*C2-A2*C1), crossprod[0])
        y = (0,crossprod[1])
        z = ((A2*D1-A1*D2)/(A1*C2-A2*C1), crossprod[2])
    else:
        return None

    return x, y, z

def line_parametric(p1, p2):
    x1, y1, z1 = p1
    x2, y2, z2 = p2
    return (x2,x1-x2), (y2,y1-y2), (z2,z1-z2)

def solve_2_by_2(row1, row2):
    a1, b1, c1 = row1
    a2, b2, c2 = row2
    if a1*b2-b1*a2:
        return (c1*b2-b1*c2)/(a1*b2-b1*a2), (a1*c2-c1*a2)/(a1*b2-b1*a2)
    else:
        return None

def sgn(x):
    return 1 if x>0 else 0 if x==0 else -1

def lines_intersection_point(i1, i2):
    x1, y1, z1 = i1
    x2, y2, z2 = i2

    try:
        t1, t2 = solve_2_by_2([x1[1], -x2[1], x2[0]-x1[0]], [y1[1], -y2[1], y2[0]-y1[0]])
        if abs(t1*z1[1] - t2*z2[1] - z2[0] + z1[0]) < EPS:
            return (x1[0]+t1*x1[1], y1[0]+t1*y1[1], z1[0]+t1*z1[1]), t2
        else:
            return None
    except:
        try:
            t1, t2 = solve_2_by_2([x1[1], -x2[1], x2[0]-x1[0]], [z1[1], -z2[1], z2[0]-z1[0]])
            if abs(t1*y1[1] - t2*y2[1] - y2[0] + y1[0]) < EPS:
                return (x1[0]+t1*x1[1], y1[0]+t1*y1[1], z1[0]+t1*z1[1]), t2
            else:
                return None
        except:
            try:
                t1, t2 = solve_2_by_2([y1[1], -y2[1], y2[0]-y1[0]], [z1[1], -z2[1], z2[0]-z1[0]])
                if abs(t1*x1[1] - t2*x2[1] - x2[0] + x1[0]) < EPS:
                    return (x1[0]+t1*x1[1], y1[0]+t1*y1[1], z1[0]+t1*z1[1]), t2
                else:
                    return None
            except:
                return None

def foo(points):
    down_cnt, up_cnt = 0, 0
    first = points[0]
    other = 1-first
    down = True
    intrusion = True
    for p in points[1:]:
        if p==first:
            intrusion = not intrusion
        else:
            if intrusion:
                if down:
                    down_cnt+=1
                else:
                    up_cnt+=1
            down = not down
    return down_cnt==up_cnt

def populate(plane, poly, tag):
    res = []
    prev = plane_value(plane,poly[-1])
    prev_serious = plane_value(plane,poly[-2]) if not prev else prev
    p_prev = poly[-1]
    for i in range(len(poly)+1):
        p = poly[i%len(poly)]
        curr = plane_value(plane,p)
        if sgn(curr) == -sgn(prev_serious):
            intersector = line_parametric(p_prev,p)
            point, t = lines_intersection_point(intersector,intersectee)
            res.append((t,tag))
            prev_serious = curr
        if sgn(curr):
            prev_serious = curr
        prev, p_prev = curr, p
    return res

x_poly, y_poly = [], []

for _ in range(inp()):
    x_poly.append(inlt())
for _ in range(inp()):
    y_poly.append(inlt())

x_plane = plane(*x_poly[:3])
y_plane = plane(*y_poly[:3])

intersectee = intersection_of_two_planes(x_plane,y_plane)

if intersectee:
    points = sorted(set(populate(y_plane,x_poly,0) + populate(x_plane,y_poly,1)))
    points = [i[1] for i in points]

    print('NO' if foo(points) else 'YES')
else:
    print('NO')


from math import gcd, sqrt
from functools import reduce

EPS = 0.000000000001

def inp():
    return(int(input()))

def inlt():
    return(list(map(int,input().split())))

def GCD(args):
    return reduce(gcd, args)

def plane_value(plane, point):
    A, B, C, D = plane
    x, y, z = point
    return A*x + B*y + C*z + D

def plane(p1, p2, p3):
    x1, y1, z1 = p1
    x2, y2, z2 = p2
    x3, y3, z3 = p3
    a1, b1, c1 = x2 - x1, y2 - y1, z2 - z1
    a2, b2, c2 = x3 - x1, y3 - y1, z3 - z1
    a, b, c = b1 * c2 - b2 * c1, a2 * c1 - a1 * c2, a1 * b2 - b1 * a2
    d = (- a * x1 - b * y1 - c * z1)
    return a, b, c, d

def cross(a, b):
    return (a[1]*b[2]-a[2]*b[1], a[2]*b[0]-a[0]*b[2], a[0]*b[1]-a[1]*b[0])

def intersection_of_two_planes(p1, p2):
    A1, B1, C1, D1 = p1
    A2, B2, C2, D2 = p2

    crossprod = cross([A1,B1,C1],[A2,B2,C2])

    if (A1*B2-A2*B1) != 0:
        x = ((B1*D2-B2*D1)/(A1*B2-A2*B1), crossprod[0])
        y = ((A2*D1-A1*D2)/(A1*B2-A2*B1), crossprod[1])
        z = (0,crossprod[2])
    elif (B1*C2-B2*C1) != 0:
        x = (0,crossprod[0])
        y = ((C1*D2-C2*D1)/(B1*C2-B2*C1), crossprod[1])
        z = ((B2*D1-B1*D2)/(B1*C2-B2*C1), crossprod[2])
    elif (A1*C2-A2*C1) != 0:
        x = ((C1*D2-C2*D1)/(A1*C2-A2*C1), crossprod[0])
        y = (0,crossprod[1])
        z = ((A2*D1-A1*D2)/(A1*C2-A2*C1), crossprod[2])
    else:
        return None

    return x, y, z

def line_parametric(p1, p2):
    x1, y1, z1 = p1
    x2, y2, z2 = p2
    return (x2,x1-x2), (y2,y1-y2), (z2,z1-z2)

def solve_2_by_2(row1, row2):
    a1, b1, c1 = row1
    a2, b2, c2 = row2
    if a1*b2-b1*a2:
        return (c1*b2-b1*c2)/(a1*b2-b1*a2), (a1*c2-c1*a2)/(a1*b2-b1*a2)
    else:
        return None

def sgn(x):
    return 1 if x>0 else 0 if x==0 else -1

def lines_intersection_point(i1, i2):
    x1, y1, z1 = i1
    x2, y2, z2 = i2

    try:
        t1, t2 = solve_2_by_2([x1[1], -x2[1], x2[0]-x1[0]], [y1[1], -y2[1], y2[0]-y1[0]])
        if abs(t1*z1[1] - t2*z2[1] - z2[0] + z1[0]) < EPS:
            return (x1[0]+t1*x1[1], y1[0]+t1*y1[1], z1[0]+t1*z1[1]), t2
        else:
            return None
    except:
        try:
            t1, t2 = solve_2_by_2([x1[1], -x2[1], x2[0]-x1[0]], [z1[1], -z2[1], z2[0]-z1[0]])
            if abs(t1*y1[1] - t2*y2[1] - y2[0] + y1[0]) < EPS:
                return (x1[0]+t1*x1[1], y1[0]+t1*y1[1], z1[0]+t1*z1[1]), t2
            else:
                return None
        except:
            try:
                t1, t2 = solve_2_by_2([y1[1], -y2[1], y2[0]-y1[0]], [z1[1], -z2[1], z2[0]-z1[0]])
                if abs(t1*x1[1] - t2*x2[1] - x2[0] + x1[0]) < EPS:
                    return (x1[0]+t1*x1[1], y1[0]+t1*y1[1], z1[0]+t1*z1[1]), t2
                else:
                    return None
            except:
                return None

def foo(points):
    down_cnt, up_cnt = 0, 0
    first = points[0]
    other = 1-first
    down = True
    intrusion = True
    for p in points[1:]:
        if p==first:
            intrusion = not intrusion
        else:
            if intrusion:
                if down:
                    down_cnt+=1
                else:
                    up_cnt+=1
            down = not down
    return down_cnt==up_cnt

def populate(plane, poly, tag):
    res = []
    prev = plane_value(plane,poly[-1])
    prev_serious = plane_value(plane,poly[-2]) if not prev else prev
    p_prev = poly[-1]
    for i in range(len(poly)+1):
        p = poly[i%len(poly)]
        curr = plane_value(plane,p)
        if sgn(curr) == -sgn(prev_serious):
            intersector = line_parametric(p_prev,p)
            point, t = lines_intersection_point(intersector,intersectee)
            res.append((t,tag))
        if sgn(curr):
            prev_serious = curr
        prev = curr
        p_prev = p
    return res

x_poly, y_poly = [], []

for _ in range(inp()):
    x_poly.append(inlt())
for _ in range(inp()):
    y_poly.append(inlt())

x_plane = plane(*x_poly[:3])
y_plane = plane(*y_poly[:3])

intersectee = intersection_of_two_planes(x_plane,y_plane)

if intersectee:
    points = sorted(set(populate(y_plane,x_poly,0) + populate(x_plane,y_poly,1)))
    points = [i[1] for i in points]

    print('NO' if foo(points) else 'YES')
else:
    print('NO')


from math import gcd, sqrt
from functools import reduce

EPS = 0.0000000001

def inp():
    return(int(input()))

def inlt():
    return(list(map(int,input().split())))

def GCD(args):
    return reduce(gcd, args)

def plane_value(plane, point):
    A, B, C, D = plane
    x, y, z = point
    return A*x + B*y + C*z + D

def plane(p1, p2, p3):
    x1, y1, z1 = p1
    x2, y2, z2 = p2
    x3, y3, z3 = p3
    a1, b1, c1 = x2 - x1, y2 - y1, z2 - z1
    a2, b2, c2 = x3 - x1, y3 - y1, z3 - z1
    a, b, c = b1 * c2 - b2 * c1, a2 * c1 - a1 * c2, a1 * b2 - b1 * a2
    d = (- a * x1 - b * y1 - c * z1)
    return a, b, c, d

def cross(a, b):
    return (a[1]*b[2]-a[2]*b[1], a[2]*b[0]-a[0]*b[2], a[0]*b[1]-a[1]*b[0])

def intersection_of_two_planes(p1, p2):
    A1, B1, C1, D1 = p1
    A2, B2, C2, D2 = p2

    crossprod = cross([A1,B1,C1],[A2,B2,C2])

    if (A1*B2-A2*B1) != 0:
        x = ((B1*D2-B2*D1)/(A1*B2-A2*B1), crossprod[0])
        y = ((A2*D1-A1*D2)/(A1*B2-A2*B1), crossprod[1])
        z = (0,crossprod[2])
    elif (B1*C2-B2*C1) != 0:
        x = (0,crossprod[0])
        y = ((C1*D2-C2*D1)/(B1*C2-B2*C1), crossprod[1])
        z = ((B2*D1-B1*D2)/(B1*C2-B2*C1), crossprod[2])
    elif (A1*C2-A2*C1) != 0:
        x = ((C1*D2-C2*D1)/(A1*C2-A2*C1), crossprod[0])
        y = (0,crossprod[1])
        z = ((A2*D1-A1*D2)/(A1*C2-A2*C1), crossprod[2])
    else:
        return None

    return x, y, z

def line_parametric(p1, p2):
    x1, y1, z1 = p1
    x2, y2, z2 = p2
    return (x2,x1-x2), (y2,y1-y2), (z2,z1-z2)

def solve_2_by_2(row1, row2):
    a1, b1, c1 = row1
    a2, b2, c2 = row2
    if a1*b2-b1*a2:
        return (c1*b2-b1*c2)/(a1*b2-b1*a2), (a1*c2-c1*a2)/(a1*b2-b1*a2)
    else:
        return None

def sgn(x):
    return 1 if x>0 else 0 if x==0 else -1

def lines_intersection_point(i1, i2):
    x1, y1, z1 = i1
    x2, y2, z2 = i2

    try:
        t1, t2 = solve_2_by_2([x1[1], -x2[1], x2[0]-x1[0]], [y1[1], -y2[1], y2[0]-y1[0]])
        if abs(t1*z1[1] - t2*z2[1] - z2[0] + z1[0]) < EPS:
            return (x1[0]+t1*x1[1], y1[0]+t1*y1[1], z1[0]+t1*z1[1]), t2
        else:
            return None
    except:
        try:
            t1, t2 = solve_2_by_2([x1[1], -x2[1], x2[0]-x1[0]], [z1[1], -z2[1], z2[0]-z1[0]])
            if abs(t1*y1[1] - t2*y2[1] - y2[0] + y1[0]) < EPS:
                return (x1[0]+t1*x1[1], y1[0]+t1*y1[1], z1[0]+t1*z1[1]), t2
            else:
                return None
        except:
            try:
                t1, t2 = solve_2_by_2([y1[1], -y2[1], y2[0]-y1[0]], [z1[1], -z2[1], z2[0]-z1[0]])
                if abs(t1*x1[1] - t2*x2[1] - x2[0] + x1[0]) < EPS:
                    return (x1[0]+t1*x1[1], y1[0]+t1*y1[1], z1[0]+t1*z1[1]), t2
                else:
                    return None
            except:
                return None

def crop(points):
    res = []
    prev = None
    cnt = 0
    for p in points:
        if p == prev:
            cnt+=1
        else:
            if cnt & 1:
                res.append(prev)
            cnt = 1
            prev = p
    if cnt & 1:
        res.append(prev)

    return res

def populate(plane, poly, tag):
    res = []
    prev = plane_value(plane,poly[-1])
    prev_serious = plane_value(plane,poly[-2]) if not prev else prev
    for i in range(len(poly)+1):
        p = poly[i%len(poly)]
        curr = plane_value(plane,p)
        if sgn(curr) == -sgn(prev_serious):
            p_prev = poly[(i-1)%len(poly)]
            intersector = line_parametric(p_prev,p)
            point, t = lines_intersection_point(intersector,intersectee)
            res.append((t,tag))
        if sgn(curr):
            prev_serious = curr
        prev = curr
    return res

x_poly, y_poly = [], []

for _ in range(inp()):
    x_poly.append(inlt())
for _ in range(inp()):
    y_poly.append(inlt())

x_plane = plane(*x_poly[:3])
y_plane = plane(*y_poly[:3])

intersectee = intersection_of_two_planes(x_plane,y_plane)

if intersectee:
    points = populate(y_plane,x_poly,0) + populate(x_plane,y_poly,1)
    points = [i[1] for i in sorted(set(points), key=lambda t: t[0])]

    prev = len(points) + 1
    while prev > len(points):
        prev = len(points)
        points = crop(points)

    print('NO' if not len(points) else 'YES')
else:
    print('NO')


from math import gcd, sqrt
from functools import reduce

EPS = 0.0000000001

def inp():
    return(int(input()))

def inlt():
    return(list(map(int,input().split())))

def GCD(args):
    return reduce(gcd, args)

def plane_value(plane, point):
    A, B, C, D = plane
    x, y, z = point
    return A*x + B*y + C*z + D

def plane(p1, p2, p3):
    x1, y1, z1 = p1
    x2, y2, z2 = p2
    x3, y3, z3 = p3
    a1, b1, c1 = x2 - x1, y2 - y1, z2 - z1
    a2, b2, c2 = x3 - x1, y3 - y1, z3 - z1
    a, b, c = b1 * c2 - b2 * c1, a2 * c1 - a1 * c2, a1 * b2 - b1 * a2
    d = (- a * x1 - b * y1 - c * z1)
    return a, b, c, d

def cross(a, b):
    return (a[1]*b[2]-a[2]*b[1], a[2]*b[0]-a[0]*b[2], a[0]*b[1]-a[1]*b[0])

def intersection_of_two_planes(p1, p2):
    A1, B1, C1, D1 = p1
    A2, B2, C2, D2 = p2

    crossprod = cross([A1,B1,C1],[A2,B2,C2])

    if (A1*B2-A2*B1) != 0:
        x = ((B1*D2-B2*D1)/(A1*B2-A2*B1), crossprod[0])
        y = ((A2*D1-A1*D2)/(A1*B2-A2*B1), crossprod[1])
        z = (0,crossprod[2])
    elif (B1*C2-B2*C1) != 0:
        x = (0,crossprod[0])
        y = ((C1*D2-C2*D1)/(B1*C2-B2*C1), crossprod[1])
        z = ((B2*D1-B1*D2)/(B1*C2-B2*C1), crossprod[2])
    elif (A1*C2-A2*C1) != 0:
        x = ((C1*D2-C2*D1)/(A1*C2-A2*C1), crossprod[0])
        y = (0,crossprod[1])
        z = ((A2*D1-A1*D2)/(A1*C2-A2*C1), crossprod[2])
    else:
        return None

    return x, y, z

def line_parametric(p1, p2):
    x1, y1, z1 = p1
    x2, y2, z2 = p2
    return (x2,x1-x2), (y2,y1-y2), (z2,z1-z2)

def solve_2_by_2(row1, row2):
    a1, b1, c1 = row1
    a2, b2, c2 = row2
    if a1*b2-b1*a2:
        return (c1*b2-b1*c2)/(a1*b2-b1*a2), (a1*c2-c1*a2)/(a1*b2-b1*a2)
    else:
        return None

def sgn(x):
    return 1 if x>0 else 0 if x==0 else -1

def lines_intersection_point(i1, i2):
    x1, y1, z1 = i1
    x2, y2, z2 = i2

    try:
        t1, t2 = solve_2_by_2([x1[1], -x2[1], x2[0]-x1[0]], [y1[1], -y2[1], y2[0]-y1[0]])
        if abs(t1*z1[1] - t2*z2[1] - z2[0] + z1[0]) < EPS:
            return (x1[0]+t1*x1[1], y1[0]+t1*y1[1], z1[0]+t1*z1[1]), t2
        else:
            return None
    except:
        try:
            t1, t2 = solve_2_by_2([x1[1], -x2[1], x2[0]-x1[0]], [z1[1], -z2[1], z2[0]-z1[0]])
            if abs(t1*y1[1] - t2*y2[1] - y2[0] + y1[0]) < EPS:
                return (x1[0]+t1*x1[1], y1[0]+t1*y1[1], z1[0]+t1*z1[1]), t2
            else:
                return None
        except:
            try:
                t1, t2 = solve_2_by_2([y1[1], -y2[1], y2[0]-y1[0]], [z1[1], -z2[1], z2[0]-z1[0]])
                if abs(t1*x1[1] - t2*x2[1] - x2[0] + x1[0]) < EPS:
                    return (x1[0]+t1*x1[1], y1[0]+t1*y1[1], z1[0]+t1*z1[1]), t2
                else:
                    return None
            except:
                return None

def crop(points):
    res = []
    prev = None
    cnt = 0
    for p in points:
        if p == prev:
            cnt+=1
        else:
            if cnt & 1:
                res.append(prev)
            cnt = 1
            prev = p
    if cnt & 1:
        res.append(prev)

    return res

def populate(plane, poly, tag):
    res = []
    prev = plane_value(plane,poly[-1])
    prev_serious = plane_value(plane,poly[-2]) if not prev else prev
    for i in range(len(poly)+1):
        p = poly[i%len(poly)]
        curr = plane_value(plane,p)
        if sgn(curr) == -sgn(prev_serious):
            p_prev = poly[(i-1)%len(poly)]
            intersector = line_parametric(p_prev,p)
            point, t = lines_intersection_point(intersector,intersectee)
            res.append((t,tag))
        if sgn(curr):
            prev_serious = curr
        prev = curr
    return res

x_poly, y_poly = [], []

for _ in range(inp()):
    x_poly.append(inlt())
for _ in range(inp()):
    y_poly.append(inlt())

x_plane = plane(*x_poly[:3])
y_plane = plane(*y_poly[:3])

intersectee = intersection_of_two_planes(x_plane,y_plane)

if intersectee:
    points = populate(y_plane,x_poly,0) + populate(x_plane,y_poly,1)
    points = [i[1] for i in sorted(points, key=lambda t: t[0])]

    prev = len(points) + 1
    while prev > len(points):
        prev = len(points)
        points = crop(points)

    print('NO' if not len(points) else 'YES')
else:
    print('NO')


from math import gcd, sqrt
from functools import reduce

EPS = 0.000000000001

def inp():
    return(int(input()))

def inlt():
    return(list(map(int,input().split())))

def GCD(args):
    return reduce(gcd, args)

def plane_value(plane, point):
    A, B, C, D = plane
    x, y, z = point
    return A*x + B*y + C*z + D

def plane(p1, p2, p3):
    x1, y1, z1 = p1
    x2, y2, z2 = p2
    x3, y3, z3 = p3
    a1, b1, c1 = x2 - x1, y2 - y1, z2 - z1
    a2, b2, c2 = x3 - x1, y3 - y1, z3 - z1
    a, b, c = b1 * c2 - b2 * c1, a2 * c1 - a1 * c2, a1 * b2 - b1 * a2
    d = (- a * x1 - b * y1 - c * z1)
    return a, b, c, d

def cross(a, b):
    return (a[1]*b[2]-a[2]*b[1], a[2]*b[0]-a[0]*b[2], a[0]*b[1]-a[1]*b[0])

def intersection_of_two_planes(p1, p2):
    A1, B1, C1, D1 = p1
    A2, B2, C2, D2 = p2

    crossprod = cross([A1,B1,C1],[A2,B2,C2])

    if (A1*B2-A2*B1) != 0:
        x = ((B1*D2-B2*D1)/(A1*B2-A2*B1), crossprod[0])
        y = ((A2*D1-A1*D2)/(A1*B2-A2*B1), crossprod[1])
        z = (0,crossprod[2])
    elif (B1*C2-B2*C1) != 0:
        x = (0,crossprod[0])
        y = ((C1*D2-C2*D1)/(B1*C2-B2*C1), crossprod[1])
        z = ((B2*D1-B1*D2)/(B1*C2-B2*C1), crossprod[2])
    elif (A1*C2-A2*C1) != 0:
        x = ((C1*D2-C2*D1)/(A1*C2-A2*C1), crossprod[0])
        y = (0,crossprod[1])
        z = ((A2*D1-A1*D2)/(A1*C2-A2*C1), crossprod[2])
    else:
        return None

    return x, y, z

def line_parametric(p1, p2):
    x1, y1, z1 = p1
    x2, y2, z2 = p2
    return (x2,x1-x2), (y2,y1-y2), (z2,z1-z2)

def solve_2_by_2(row1, row2):
    a1, b1, c1 = row1
    a2, b2, c2 = row2
    if a1*b2-b1*a2:
        return (c1*b2-b1*c2)/(a1*b2-b1*a2), (a1*c2-c1*a2)/(a1*b2-b1*a2)
    else:
        return None

def sgn(x):
    return 1 if x>0 else 0 if x==0 else -1

def lines_intersection_point(i1, i2):
    x1, y1, z1 = i1
    x2, y2, z2 = i2

    try:
        t1, t2 = solve_2_by_2([x1[1], -x2[1], x2[0]-x1[0]], [y1[1], -y2[1], y2[0]-y1[0]])
        if abs(t1*z1[1] - t2*z2[1] - z2[0] + z1[0]) < EPS:
            return (x1[0]+t1*x1[1], y1[0]+t1*y1[1], z1[0]+t1*z1[1]), t2
        else:
            return None
    except:
        try:
            t1, t2 = solve_2_by_2([x1[1], -x2[1], x2[0]-x1[0]], [z1[1], -z2[1], z2[0]-z1[0]])
            if abs(t1*y1[1] - t2*y2[1] - y2[0] + y1[0]) < EPS:
                return (x1[0]+t1*x1[1], y1[0]+t1*y1[1], z1[0]+t1*z1[1]), t2
            else:
                return None
        except:
            try:
                t1, t2 = solve_2_by_2([y1[1], -y2[1], y2[0]-y1[0]], [z1[1], -z2[1], z2[0]-z1[0]])
                if abs(t1*x1[1] - t2*x2[1] - x2[0] + x1[0]) < EPS:
                    return (x1[0]+t1*x1[1], y1[0]+t1*y1[1], z1[0]+t1*z1[1]), t2
                else:
                    return None
            except:
                return None

def crop(points):
    res = []
    prev = None
    cnt = 0
    for p in points:
        if p == prev:
            cnt+=1
        else:
            if cnt & 1:
                res.append(prev)
            cnt = 1
            prev = p
    if cnt & 1:
        res.append(prev)

    return res

def populate(plane, poly, tag):
    res = []
    prev = plane_value(plane,poly[-1])
    prev_serious = plane_value(plane,poly[-2]) if not prev else prev
    for i in range(len(poly)+1):
        p = poly[i%len(poly)]
        curr = plane_value(plane,p)
        if sgn(curr) == -sgn(prev_serious):
            p_prev = poly[(i-1)%len(poly)]
            intersector = line_parametric(p_prev,p)
            point, t = lines_intersection_point(intersector,intersectee)
            res.append((t,tag))
        if sgn(curr):
            prev_serious = curr
        prev = curr
    return res

x_poly, y_poly = [], []

for _ in range(inp()):
    x_poly.append(inlt())
for _ in range(inp()):
    y_poly.append(inlt())

x_plane = plane(*x_poly[:3])
y_plane = plane(*y_poly[:3])

intersectee = intersection_of_two_planes(x_plane,y_plane)

if intersectee:
    points = populate(y_plane,x_poly,0) + populate(x_plane,y_poly,1)
    points = [i[1] for i in sorted(set(points), key=lambda t: t[0])]

    prev = len(points) + 1
    while prev > len(points):
        prev = len(points)
        points = crop(points)

    print('NO' if not len(points) else 'YES')
else:
    print('NO')


from math import gcd, sqrt
from functools import reduce

EPS = 0.000000000001

def inp():
    return(int(input()))

def inlt():
    return(list(map(int,input().split())))

def GCD(args):
    return reduce(gcd, args)

def plane_value(plane, point):
    A, B, C, D = plane
    x, y, z = point
    return A*x + B*y + C*z + D

def plane(p1, p2, p3):
    x1, y1, z1 = p1
    x2, y2, z2 = p2
    x3, y3, z3 = p3
    a1, b1, c1 = x2 - x1, y2 - y1, z2 - z1
    a2, b2, c2 = x3 - x1, y3 - y1, z3 - z1
    a, b, c = b1 * c2 - b2 * c1, a2 * c1 - a1 * c2, a1 * b2 - b1 * a2
    d = (- a * x1 - b * y1 - c * z1)
    return a, b, c, d

def cross(a, b):
    return (a[1]*b[2]-a[2]*b[1], a[2]*b[0]-a[0]*b[2], a[0]*b[1]-a[1]*b[0])

def intersection_of_two_planes(p1, p2):
    A1, B1, C1, D1 = p1
    A2, B2, C2, D2 = p2
#
    crossprod = cross([A1,B1,C1],[A2,B2,C2])

    if (A1*B2-A2*B1) != 0:
        x = ((B1*D2-B2*D1)/(A1*B2-A2*B1), crossprod[0])
        y = ((A2*D1-A1*D2)/(A1*B2-A2*B1), crossprod[1])
        z = (0,crossprod[2])
    elif (B1*C2-B2*C1) != 0:
        x = (0,crossprod[0])
        y = ((C1*D2-C2*D1)/(B1*C2-B2*C1), crossprod[1])
        z = ((B2*D1-B1*D2)/(B1*C2-B2*C1), crossprod[2])
    elif (A1*C2-A2*C1) != 0:
        x = ((C1*D2-C2*D1)/(A1*C2-A2*C1), crossprod[0])
        y = (0,crossprod[1])
        z = ((A2*D1-A1*D2)/(A1*C2-A2*C1), crossprod[2])
    else:
        return None

    return x, y, z

def line_parametric(p1, p2):
    x1, y1, z1 = p1
    x2, y2, z2 = p2
    return (x2,x1-x2), (y2,y1-y2), (z2,z1-z2)

def solve_2_by_2(row1, row2):
    a1, b1, c1 = row1
    a2, b2, c2 = row2
    if a1*b2-b1*a2:
        return (c1*b2-b1*c2)/(a1*b2-b1*a2), (a1*c2-c1*a2)/(a1*b2-b1*a2)
    else:
        return None

def sgn(x):
    return 1 if x>0 else 0 if x==0 else -1

def lines_intersection_point(i1, i2):
    x1, y1, z1 = i1
    x2, y2, z2 = i2

    try:
        t1, t2 = solve_2_by_2([x1[1], -x2[1], x2[0]-x1[0]], [y1[1], -y2[1], y2[0]-y1[0]])
        if abs(t1*z1[1] - t2*z2[1] - z2[0] + z1[0]) < EPS:
            return (x1[0]+t1*x1[1], y1[0]+t1*y1[1], z1[0]+t1*z1[1]), t2
        else:
            return None
    except:
        try:
            t1, t2 = solve_2_by_2([x1[1], -x2[1], x2[0]-x1[0]], [z1[1], -z2[1], z2[0]-z1[0]])
            if abs(t1*y1[1] - t2*y2[1] - y2[0] + y1[0]) < EPS:
                return (x1[0]+t1*x1[1], y1[0]+t1*y1[1], z1[0]+t1*z1[1]), t2
            else:
                return None
        except:
            try:
                t1, t2 = solve_2_by_2([y1[1], -y2[1], y2[0]-y1[0]], [z1[1], -z2[1], z2[0]-z1[0]])
                if abs(t1*x1[1] - t2*x2[1] - x2[0] + x1[0]) < EPS:
                    return (x1[0]+t1*x1[1], y1[0]+t1*y1[1], z1[0]+t1*z1[1]), t2
                else:
                    return None
            except:
                return None

def foo(points):
    down_cnt, up_cnt = 0, 0
    first = points[0]
    other = 1-first
    down = True
    intrusion = True
    for p in points[1:]:
        if p==first:
            intrusion = not intrusion
        else:
            if intrusion:
                if down:
                    down_cnt+=1
                else:
                    up_cnt+=1
            down = not down
    return down_cnt==up_cnt

def populate(plane, poly, tag):
    res = []
    prev = plane_value(plane,poly[-1])
    prev_serious = plane_value(plane,poly[-2]) if not prev else prev
    p_prev = poly[-1]
    for i in range(len(poly)+1):
        p = poly[i%len(poly)]
        curr = plane_value(plane,p)
        if sgn(curr) == -sgn(prev_serious):
            intersector = line_parametric(p_prev,p)
            point, t = lines_intersection_point(intersector,intersectee)
            res.append((t,tag))
        if sgn(curr):
            prev_serious = curr
        prev = curr
        p_prev = p
    return res

x_poly, y_poly = [], []

for _ in range(inp()):
    x_poly.append(inlt())
for _ in range(inp()):
    y_poly.append(inlt())

x_plane = plane(*x_poly[:3])
y_plane = plane(*y_poly[:3])

intersectee = intersection_of_two_planes(x_plane,y_plane)

if intersectee:
    points = sorted(set(populate(y_plane,x_poly,0) + populate(x_plane,y_poly,1)))
    points = [i[1] for i in points]

    print('NO' if foo(points) else 'YES')
else:
    print('NO')


from math import gcd, sqrt
from functools import reduce

EPS = 0.000000000001

def inp():
    return(int(input()))

def inlt():
    return(list(map(int,input().split())))

def GCD(args):
    return reduce(gcd, args)

def plane_value(plane, point):
    A, B, C, D = plane
    x, y, z = point
    return A*x + B*y + C*z + D

def plane(p1, p2, p3):
    x1, y1, z1 = p1
    x2, y2, z2 = p2
    x3, y3, z3 = p3
    a1, b1, c1 = x2 - x1, y2 - y1, z2 - z1
    a2, b2, c2 = x3 - x1, y3 - y1, z3 - z1
    a, b, c = b1 * c2 - b2 * c1, a2 * c1 - a1 * c2, a1 * b2 - b1 * a2
    d = (- a * x1 - b * y1 - c * z1)
    return a, b, c, d

def cross(a, b):
    return (a[1]*b[2]-a[2]*b[1], a[2]*b[0]-a[0]*b[2], a[0]*b[1]-a[1]*b[0])

def intersection_of_two_planes(p1, p2):
    A1, B1, C1, D1 = p1
    A2, B2, C2, D2 = p2

    crossprod = cross([A1,B1,C1],[A2,B2,C2])

    if (A1*B2-A2*B1) != 0:
        x = ((B1*D2-B2*D1)/(A1*B2-A2*B1), crossprod[0])
        y = ((A2*D1-A1*D2)/(A1*B2-A2*B1), crossprod[1])
        z = (0,crossprod[2])
    elif (B1*C2-B2*C1) != 0:
        x = (0,crossprod[0])
        y = ((C1*D2-C2*D1)/(B1*C2-B2*C1), crossprod[1])
        z = ((B2*D1-B1*D2)/(B1*C2-B2*C1), crossprod[2])
    elif (A1*C2-A2*C1) != 0:
        x = ((C1*D2-C2*D1)/(A1*C2-A2*C1), crossprod[0])
        y = (0,crossprod[1])
        z = ((A2*D1-A1*D2)/(A1*C2-A2*C1), crossprod[2])
    else:
        return None

    return x, y, z

def line_parametric(p1, p2):
    x1, y1, z1 = p1
    x2, y2, z2 = p2
    return (x2,x1-x2), (y2,y1-y2), (z2,z1-z2)

def solve_2_by_2(row1, row2):
    a1, b1, c1 = row1
    a2, b2, c2 = row2
    if a1*b2-b1*a2:
        return (c1*b2-b1*c2)/(a1*b2-b1*a2), (a1*c2-c1*a2)/(a1*b2-b1*a2)
    else:
        return None

def sgn(x):
    return 1 if x>0 else 0 if x==0 else -1

def lines_intersection_point(i1, i2):
    x1, y1, z1 = i1
    x2, y2, z2 = i2

    try:
        t1, t2 = solve_2_by_2([x1[1], -x2[1], x2[0]-x1[0]], [y1[1], -y2[1], y2[0]-y1[0]])
        if abs(t1*z1[1] - t2*z2[1] - z2[0] + z1[0]) < EPS:
            return (x1[0]+t1*x1[1], y1[0]+t1*y1[1], z1[0]+t1*z1[1]), t2
        else:
            return None
    except:
        try:
            t1, t2 = solve_2_by_2([x1[1], -x2[1], x2[0]-x1[0]], [z1[1], -z2[1], z2[0]-z1[0]])
            if abs(t1*y1[1] - t2*y2[1] - y2[0] + y1[0]) < EPS:
                return (x1[0]+t1*x1[1], y1[0]+t1*y1[1], z1[0]+t1*z1[1]), t2
            else:
                return None
        except:
            try:
                t1, t2 = solve_2_by_2([y1[1], -y2[1], y2[0]-y1[0]], [z1[1], -z2[1], z2[0]-z1[0]])
                if abs(t1*x1[1] - t2*x2[1] - x2[0] + x1[0]) < EPS:
                    return (x1[0]+t1*x1[1], y1[0]+t1*y1[1], z1[0]+t1*z1[1]), t2
                else:
                    return None
            except:
                return None

def crop(points):
    res = []
    prev = None
    cnt = 0
    for p in points:
        if p == prev:
            cnt+=1
        else:
            if cnt & 1:
                res.append(prev)
            cnt = 1
            prev = p
    if cnt & 1:
        res.append(prev)

    return res

def populate(plane, poly, tag):
    res = set()
    prev = plane_value(plane,poly[-1])
    prev_serious = plane_value(plane,poly[-2]) if not prev else prev
    for i in range(len(poly)+1):
        p = poly[i%len(poly)]
        curr = plane_value(plane,p)
        if sgn(curr) == -sgn(prev_serious):
            p_prev = poly[(i-1)%len(poly)]
            intersector = line_parametric(p_prev,p)
            point, t = lines_intersection_point(intersector,intersectee)
            res.add((t,tag))
        if sgn(curr):
            prev_serious = curr
        prev = curr
    return res

x_poly, y_poly = [], []

for _ in range(inp()):
    x_poly.append(inlt())
for _ in range(inp()):
    y_poly.append(inlt())

x_plane = plane(*x_poly[:3])
y_plane = plane(*y_poly[:3])

intersectee = intersection_of_two_planes(x_plane,y_plane)

if intersectee:
    points = set()
    points = sorted(populate(y_plane,x_poly,0) + populate(x_plane,y_poly,1))
    points = [i[1] for i in points]

    prev = len(points) + 1
    while prev > len(points):
        prev = len(points)
        points = crop(points)

    print('NO' if not len(points) else 'YES')
else:
    print('NO')


from math import gcd, sqrt
from functools import reduce

EPS = 0.0000000001

def inp():
    return(int(input()))

def inlt():
    return(list(map(int,input().split())))

def GCD(args):
    return reduce(gcd, args)

def plane_value(plane, point):
    A, B, C, D = plane
    x, y, z = point
    return A*x + B*y + C*z + D

def plane(p1, p2, p3):
    x1, y1, z1 = p1
    x2, y2, z2 = p2
    x3, y3, z3 = p3
    a1, b1, c1 = x2 - x1, y2 - y1, z2 - z1
    a2, b2, c2 = x3 - x1, y3 - y1, z3 - z1
    a, b, c = b1 * c2 - b2 * c1, a2 * c1 - a1 * c2, a1 * b2 - b1 * a2
    d = (- a * x1 - b * y1 - c * z1)
    return a, b, c, d

def cross(a, b):
    return (a[1]*b[2]-a[2]*b[1], a[2]*b[0]-a[0]*b[2], a[0]*b[1]-a[1]*b[0])

def intersection_of_two_planes(p1, p2):
    A1, B1, C1, D1 = p1
    A2, B2, C2, D2 = p2

    crossprod = cross([A1,B1,C1],[A2,B2,C2])

    if (A1*B2-A2*B1) != 0:
        x = ((B1*D2-B2*D1)/(A1*B2-A2*B1), crossprod[0])
        y = ((A2*D1-A1*D2)/(A1*B2-A2*B1), crossprod[1])
        z = (0,crossprod[2])
    elif (B1*C2-B2*C1) != 0:
        x = (0,crossprod[0])
        y = ((C1*D2-C2*D1)/(B1*C2-B2*C1), crossprod[1])
        z = ((B2*D1-B1*D2)/(B1*C2-B2*C1), crossprod[2])
    elif (A1*C2-A2*C1) != 0:
        x = ((C1*D2-C2*D1)/(A1*C2-A2*C1), crossprod[0])
        y = (0,crossprod[1])
        z = ((A2*D1-A1*D2)/(A1*C2-A2*C1), crossprod[2])
    else:
        return None

    return x, y, z

def line_parametric(p1, p2):
    x1, y1, z1 = p1
    x2, y2, z2 = p2
    return (x2,x1-x2), (y2,y1-y2), (z2,z1-z2)

def solve_2_by_2(row1, row2):
    a1, b1, c1 = row1
    a2, b2, c2 = row2
    if a1*b2-b1*a2:
        return (c1*b2-b1*c2)/(a1*b2-b1*a2), (a1*c2-c1*a2)/(a1*b2-b1*a2)
    else:
        return None

def sgn(x):
    return 1 if x>0 else 0 if x==0 else -1

def lines_intersection_point(i1, i2):
    x1, y1, z1 = i1
    x2, y2, z2 = i2

    try:
        t1, t2 = solve_2_by_2([x1[1], -x2[1], x2[0]-x1[0]], [y1[1], -y2[1], y2[0]-y1[0]])
        if abs(t1*z1[1] - t2*z2[1] - z2[0] + z1[0]) < EPS:
            return (x1[0]+t1*x1[1], y1[0]+t1*y1[1], z1[0]+t1*z1[1]), t2
        else:
            return None
    except:
        try:
            t1, t2 = solve_2_by_2([x1[1], -x2[1], x2[0]-x1[0]], [z1[1], -z2[1], z2[0]-z1[0]])
            if abs(t1*y1[1] - t2*y2[1] - y2[0] + y1[0]) < EPS:
                return (x1[0]+t1*x1[1], y1[0]+t1*y1[1], z1[0]+t1*z1[1]), t2
            else:
                return None
        except:
            try:
                t1, t2 = solve_2_by_2([y1[1], -y2[1], y2[0]-y1[0]], [z1[1], -z2[1], z2[0]-z1[0]])
                if abs(t1*x1[1] - t2*x2[1] - x2[0] + x1[0]) < EPS:
                    return (x1[0]+t1*x1[1], y1[0]+t1*y1[1], z1[0]+t1*z1[1]), t2
                else:
                    return None
            except:
                return None

def crop(points):
    res = []
    prev = None
    cnt = 0
    for p in points:
        if p == prev:
            cnt+=1
        else:
            if cnt & 1:
                res.append(prev)
            cnt = 1
            prev = p
    if cnt & 1:
        res.append(prev)

    return res

def populate(plane, poly, tag):
    res = []
    prev = plane_value(plane,poly[-1])
    prev_serious = plane_value(plane,poly[-2]) if not prev else prev
    for i in range(len(poly)+1):
        p = poly[i%len(poly)]
        curr = plane_value(plane,p)
        if sgn(curr) == -sgn(prev_serious):
            p_prev = poly[(i-1)%len(poly)]
            intersector = line_parametric(p_prev,p)
            point, t = lines_intersection_point(intersector,intersectee)
            res.append((t,tag))
        if sgn(curr):
            prev_serious = curr
        prev = curr
    return res

x_poly, y_poly = [], []

for _ in range(inp()):
    x_poly.append(inlt())
for _ in range(inp()):
    y_poly.append(inlt())

x_plane = plane(*x_poly[:3])
y_plane = plane(*y_poly[:3])

intersectee = intersection_of_two_planes(x_plane,y_plane)

if len(x_poly)>1000:
    print(1/0)

if intersectee:
    points = populate(y_plane,x_poly,0) + populate(x_plane,y_poly,1)
    points = [i[1] for i in sorted(set(points), key=lambda t: t[0])]

    prev = len(points) + 1
    while prev > len(points):
        prev = len(points)
        points = crop(points)

    print('NO' if not len(points) else 'YES')
else:
    print('NO')


from math import gcd, sqrt
from functools import reduce

EPS = 0.000000000001

def inp():
    return(int(input()))

def inlt():
    return(list(map(int,input().split())))

def GCD(args):
    return reduce(gcd, args)

def plane_value(plane, point):
    A, B, C, D = plane
    x, y, z = point
    return A*x + B*y + C*z + D

def plane(p1, p2, p3):
    x1, y1, z1 = p1
    x2, y2, z2 = p2
    x3, y3, z3 = p3
    a1, b1, c1 = x2 - x1, y2 - y1, z2 - z1
    a2, b2, c2 = x3 - x1, y3 - y1, z3 - z1
    a, b, c = b1 * c2 - b2 * c1, a2 * c1 - a1 * c2, a1 * b2 - b1 * a2
    d = (- a * x1 - b * y1 - c * z1)
    return a, b, c, d

def cross(a, b):
    return (a[1]*b[2]-a[2]*b[1], a[2]*b[0]-a[0]*b[2], a[0]*b[1]-a[1]*b[0])

def intersection_of_two_planes(p1, p2):
    A1, B1, C1, D1 = p1
    A2, B2, C2, D2 = p2

    crossprod = cross([A1,B1,C1],[A2,B2,C2])

    if (A1*B2-A2*B1) != 0:
        x = ((B1*D2-B2*D1)/(A1*B2-A2*B1), crossprod[0])
        y = ((A2*D1-A1*D2)/(A1*B2-A2*B1), crossprod[1])
        z = (0,crossprod[2])
    elif (B1*C2-B2*C1) != 0:
        x = (0,crossprod[0])
        y = ((C1*D2-C2*D1)/(B1*C2-B2*C1), crossprod[1])
        z = ((B2*D1-B1*D2)/(B1*C2-B2*C1), crossprod[2])
    elif (A1*C2-A2*C1) != 0:
        x = ((C1*D2-C2*D1)/(A1*C2-A2*C1), crossprod[0])
        y = (0,crossprod[1])
        z = ((A2*D1-A1*D2)/(A1*C2-A2*C1), crossprod[2])
    else:
        return None

    return x, y, z

def line_parametric(p1, p2):
    x1, y1, z1 = p1
    x2, y2, z2 = p2
    return (x2,x1-x2), (y2,y1-y2), (z2,z1-z2)

def solve_2_by_2(row1, row2):
    a1, b1, c1 = row1
    a2, b2, c2 = row2
    if a1*b2-b1*a2:
        return (c1*b2-b1*c2)/(a1*b2-b1*a2), (a1*c2-c1*a2)/(a1*b2-b1*a2)
    else:
        return None

def sgn(x):
    return 1 if x>0 else 0 if x==0 else -1

def lines_intersection_point(i1, i2):
    x1, y1, z1 = i1
    x2, y2, z2 = i2

    try:
        t1, t2 = solve_2_by_2([x1[1], -x2[1], x2[0]-x1[0]], [y1[1], -y2[1], y2[0]-y1[0]])
        if abs(t1*z1[1] - t2*z2[1] - z2[0] + z1[0]) < EPS:
            return (x1[0]+t1*x1[1], y1[0]+t1*y1[1], z1[0]+t1*z1[1]), t2
        else:
            return None
    except:
        try:
            t1, t2 = solve_2_by_2([x1[1], -x2[1], x2[0]-x1[0]], [z1[1], -z2[1], z2[0]-z1[0]])
            if abs(t1*y1[1] - t2*y2[1] - y2[0] + y1[0]) < EPS:
                return (x1[0]+t1*x1[1], y1[0]+t1*y1[1], z1[0]+t1*z1[1]), t2
            else:
                return None
        except:
            try:
                t1, t2 = solve_2_by_2([y1[1], -y2[1], y2[0]-y1[0]], [z1[1], -z2[1], z2[0]-z1[0]])
                if abs(t1*x1[1] - t2*x2[1] - x2[0] + x1[0]) < EPS:
                    return (x1[0]+t1*x1[1], y1[0]+t1*y1[1], z1[0]+t1*z1[1]), t2
                else:
                    return None
            except:
                return None

def crop(points):
    res = []
    prev = None
    cnt = 0
    for p in points:
        if p == prev:
            cnt+=1
        else:
            if cnt & 1:
                res.append(prev)
            cnt = 1
            prev = p
    if cnt & 1:
        res.append(prev)

    return res

def populate(plane, poly, tag):
    res = []
    prev = plane_value(plane,poly[-1])
    prev_serious = plane_value(plane,poly[-2]) if not prev else prev
    p_prev = poly[-1]
    for i in range(len(poly)+1):
        p = poly[i%len(poly)]
        curr = plane_value(plane,p)
        if sgn(curr) == -sgn(prev_serious):
            intersector = line_parametric(p_prev,p)
            point, t = lines_intersection_point(intersector,intersectee)
            res.append((t,tag))
        if sgn(curr):
            prev_serious = curr
        prev = curr
        p_prev = p
    return res

x_poly, y_poly = [], []

for _ in range(inp()):
    x_poly.append(inlt())
for _ in range(inp()):
    y_poly.append(inlt())

x_plane = plane(*x_poly[:3])
y_plane = plane(*y_poly[:3])

intersectee = intersection_of_two_planes(x_plane,y_plane)

if intersectee:
    points = sorted(set(populate(y_plane,x_poly,0) + populate(x_plane,y_poly,1)))
    points = [i[1] for i in points]

    prev = len(points) + 1
    while prev > len(points):
        prev = len(points)
        points = crop(points)

    print('NO' if not len(points) else 'YES')
else:
    print('NO')


from math import gcd, sqrt
from functools import reduce

EPS = 0.0000000001

def inp():
    return(int(input()))

def inlt():
    return(list(map(int,input().split())))

def GCD(args):
    return reduce(gcd, args)

def plane_value(plane, point):
    A, B, C, D = plane
    x, y, z = point
    return A*x + B*y + C*z + D

def plane(p1, p2, p3):
    x1, y1, z1 = p1
    x2, y2, z2 = p2
    x3, y3, z3 = p3
    a1, b1, c1 = x2 - x1, y2 - y1, z2 - z1
    a2, b2, c2 = x3 - x1, y3 - y1, z3 - z1
    a, b, c = b1 * c2 - b2 * c1, a2 * c1 - a1 * c2, a1 * b2 - b1 * a2
    d = (- a * x1 - b * y1 - c * z1)
    return a, b, c, d

def cross(a, b):
    return (a[1]*b[2]-a[2]*b[1], a[2]*b[0]-a[0]*b[2], a[0]*b[1]-a[1]*b[0])

def intersection_of_two_planes(p1, p2):
    A1, B1, C1, D1 = p1
    A2, B2, C2, D2 = p2

    crossprod = cross([A1,B1,C1],[A2,B2,C2])

    if (A1*B2-A2*B1) != 0:
        x = ((B1*D2-B2*D1)/(A1*B2-A2*B1), crossprod[0])
        y = ((A2*D1-A1*D2)/(A1*B2-A2*B1), crossprod[1])
        z = (0,crossprod[2])
    elif (B1*C2-B2*C1) != 0:
        x = (0,crossprod[0])
        y = ((C1*D2-C2*D1)/(B1*C2-B2*C1), crossprod[1])
        z = ((B2*D1-B1*D2)/(B1*C2-B2*C1), crossprod[2])
    elif (A1*C2-A2*C1) != 0:
        x = ((C1*D2-C2*D1)/(A1*C2-A2*C1), crossprod[0])
        y = (0,crossprod[1])
        z = ((A2*D1-A1*D2)/(A1*C2-A2*C1), crossprod[2])
    else:
        return None

    return x, y, z

def line_parametric(p1, p2):
    x1, y1, z1 = p1
    x2, y2, z2 = p2
    return (x2,x1-x2), (y2,y1-y2), (z2,z1-z2)

def solve_2_by_2(row1, row2):
    a1, b1, c1 = row1
    a2, b2, c2 = row2
    if a1*b2-b1*a2:
        return (c1*b2-b1*c2)/(a1*b2-b1*a2), (a1*c2-c1*a2)/(a1*b2-b1*a2)
    else:
        return None

def sgn(x):
    return 1 if x>0 else 0 if x==0 else -1

def lines_intersection_point(i1, i2):
    x1, y1, z1 = i1
    x2, y2, z2 = i2

    try:
        t1, t2 = solve_2_by_2([x1[1], -x2[1], x2[0]-x1[0]], [y1[1], -y2[1], y2[0]-y1[0]])
        if abs(t1*z1[1] - t2*z2[1] - z2[0] + z1[0]) < EPS:
            return (x1[0]+t1*x1[1], y1[0]+t1*y1[1], z1[0]+t1*z1[1]), t2
        else:
            return None
    except:
        try:
            t1, t2 = solve_2_by_2([x1[1], -x2[1], x2[0]-x1[0]], [z1[1], -z2[1], z2[0]-z1[0]])
            if abs(t1*y1[1] - t2*y2[1] - y2[0] + y1[0]) < EPS:
                return (x1[0]+t1*x1[1], y1[0]+t1*y1[1], z1[0]+t1*z1[1]), t2
            else:
                return None
        except:
            try:
                t1, t2 = solve_2_by_2([y1[1], -y2[1], y2[0]-y1[0]], [z1[1], -z2[1], z2[0]-z1[0]])
                if abs(t1*x1[1] - t2*x2[1] - x2[0] + x1[0]) < EPS:
                    return (x1[0]+t1*x1[1], y1[0]+t1*y1[1], z1[0]+t1*z1[1]), t2
                else:
                    return None
            except:
                return None

def crop(points):
    res = []
    prev = None
    cnt = 0
    for p in points:
        if p == prev:
            cnt+=1
        else:
            if cnt & 1:
                res.append(prev)
            cnt = 1
            prev = p
    if cnt & 1:
        res.append(prev)

    return res

def populate(plane, poly, tag):
    res = []
    prev = plane_value(plane,poly[-1])
    prev_serious = plane_value(plane,poly[-2]) if not prev else prev
    for i in range(len(poly)+1):
        p = poly[i%len(poly)]
        curr = plane_value(plane,p)
        if sgn(curr) == -sgn(prev_serious):
            p_prev = poly[(i-1)%len(poly)]
            intersector = line_parametric(p_prev,p)
            point, t = lines_intersection_point(intersector,intersectee)
            res.append((t,tag))
        if sgn(curr):
            prev_serious = curr
        prev = curr
    return res

x_poly, y_poly = [], []

for _ in range(inp()):
    x_poly.append(inlt())
for _ in range(inp()):
    y_poly.append(inlt())

x_plane = plane(*x_poly[:3])
y_plane = plane(*y_poly[:3])

intersectee = intersection_of_two_planes(x_plane,y_plane)

if len(x_poly)>1000 or len(y_poly)>1000:
    print(1/0)

if intersectee:
    points = populate(y_plane,x_poly,0) + populate(x_plane,y_poly,1)
    points = [i[1] for i in sorted(set(points), key=lambda t: t[0])]

    prev = len(points) + 1
    while prev > len(points):
        prev = len(points)
        points = crop(points)

    print('NO' if not len(points) else 'YES')
else:
    print('NO')


from math import gcd, sqrt
from functools import reduce

EPS = 0.000000000001

def inp():
    return(int(input()))

def inlt():
    return(list(map(int,input().split())))

def GCD(args):
    return reduce(gcd, args)

def plane_value(plane, point):
    A, B, C, D = plane
    x, y, z = point
    return A*x + B*y + C*z + D

def plane(p1, p2, p3):
    x1, y1, z1 = p1
    x2, y2, z2 = p2
    x3, y3, z3 = p3
    a1, b1, c1 = x2 - x1, y2 - y1, z2 - z1
    a2, b2, c2 = x3 - x1, y3 - y1, z3 - z1
    a, b, c = b1 * c2 - b2 * c1, a2 * c1 - a1 * c2, a1 * b2 - b1 * a2
    d = (- a * x1 - b * y1 - c * z1)
    return a, b, c, d

def cross(a, b):
    return (a[1]*b[2]-a[2]*b[1], a[2]*b[0]-a[0]*b[2], a[0]*b[1]-a[1]*b[0])

def intersection_of_two_planes(p1, p2):
    A1, B1, C1, D1 = p1
    A2, B2, C2, D2 = p2

    crossprod = cross([A1,B1,C1],[A2,B2,C2])

    if (A1*B2-A2*B1) != 0:
        x = ((B1*D2-B2*D1)/(A1*B2-A2*B1), crossprod[0])
        y = ((A2*D1-A1*D2)/(A1*B2-A2*B1), crossprod[1])
        z = (0,crossprod[2])
    elif (B1*C2-B2*C1) != 0:
        x = (0,crossprod[0])
        y = ((C1*D2-C2*D1)/(B1*C2-B2*C1), crossprod[1])
        z = ((B2*D1-B1*D2)/(B1*C2-B2*C1), crossprod[2])
    elif (A1*C2-A2*C1) != 0:
        x = ((C1*D2-C2*D1)/(A1*C2-A2*C1), crossprod[0])
        y = (0,crossprod[1])
        z = ((A2*D1-A1*D2)/(A1*C2-A2*C1), crossprod[2])
    else:
        return None

    return x, y, z

def line_parametric(p1, p2):
    x1, y1, z1 = p1
    x2, y2, z2 = p2
    return (x2,x1-x2), (y2,y1-y2), (z2,z1-z2)

def solve_2_by_2(row1, row2):
    a1, b1, c1 = row1
    a2, b2, c2 = row2
    if a1*b2-b1*a2:
        return (c1*b2-b1*c2)/(a1*b2-b1*a2), (a1*c2-c1*a2)/(a1*b2-b1*a2)
    else:
        return None

def sgn(x):
    return 1 if x>0 else 0 if x==0 else -1

def lines_intersection_point(i1, i2):
    x1, y1, z1 = i1
    x2, y2, z2 = i2

    try:
        t1, t2 = solve_2_by_2([x1[1], -x2[1], x2[0]-x1[0]], [y1[1], -y2[1], y2[0]-y1[0]])
        if abs(t1*z1[1] - t2*z2[1] - z2[0] + z1[0]) < EPS:
            return (x1[0]+t1*x1[1], y1[0]+t1*y1[1], z1[0]+t1*z1[1]), t2
        else:
            return None
    except:
        try:
            t1, t2 = solve_2_by_2([x1[1], -x2[1], x2[0]-x1[0]], [z1[1], -z2[1], z2[0]-z1[0]])
            if abs(t1*y1[1] - t2*y2[1] - y2[0] + y1[0]) < EPS:
                return (x1[0]+t1*x1[1], y1[0]+t1*y1[1], z1[0]+t1*z1[1]), t2
            else:
                return None
        except:
            try:
                t1, t2 = solve_2_by_2([y1[1], -y2[1], y2[0]-y1[0]], [z1[1], -z2[1], z2[0]-z1[0]])
                if abs(t1*x1[1] - t2*x2[1] - x2[0] + x1[0]) < EPS:
                    return (x1[0]+t1*x1[1], y1[0]+t1*y1[1], z1[0]+t1*z1[1]), t2
                else:
                    return None
            except:
                return None

def crop(points):
    res = []
    prev = None
    cnt = 0
    for p in points:
        if p == prev:
            cnt+=1
        else:
            if cnt & 1:
                res.append(prev)
            cnt = 1
            prev = p
    if cnt & 1:
        res.append(prev)

    return res

def populate(plane, poly, tag):
    res = set()
    prev = plane_value(plane,poly[-1])
    prev_serious = plane_value(plane,poly[-2]) if not prev else prev
    for i in range(len(poly)+1):
        p = poly[i%len(poly)]
        curr = plane_value(plane,p)
        if sgn(curr) == -sgn(prev_serious):
            p_prev = poly[(i-1)%len(poly)]
            intersector = line_parametric(p_prev,p)
            point, t = lines_intersection_point(intersector,intersectee)
            res.add((t,tag))
        if sgn(curr):
            prev_serious = curr
        prev = curr
    return res

x_poly, y_poly = [], []

for _ in range(inp()):
    x_poly.append(inlt())
for _ in range(inp()):
    y_poly.append(inlt())

x_plane = plane(*x_poly[:3])
y_plane = plane(*y_poly[:3])

intersectee = intersection_of_two_planes(x_plane,y_plane)

if intersectee:
    points = set()
    points = sorted(populate(y_plane,x_poly,0) | populate(x_plane,y_poly,1))
    points = [i[1] for i in points]

    prev = len(points) + 1
    while prev > len(points):
        prev = len(points)
        points = crop(points)

    print('NO' if not len(points) else 'YES')
else:
    print('NO')


from math import gcd, sqrt
from functools import reduce
import sys
input = sys.stdin.readline

EPS = 0.000000000001

def inp():
    return(int(input()))

def inlt():
    return(list(map(int,input().split())))

def GCD(args):
    return reduce(gcd, args)

def plane_value(plane, point):
    A, B, C, D = plane
    x, y, z = point
    return A*x + B*y + C*z + D

def plane(p1, p2, p3):
    x1, y1, z1 = p1
    x2, y2, z2 = p2
    x3, y3, z3 = p3
    a1, b1, c1 = x2 - x1, y2 - y1, z2 - z1
    a2, b2, c2 = x3 - x1, y3 - y1, z3 - z1
    a, b, c = b1 * c2 - b2 * c1, a2 * c1 - a1 * c2, a1 * b2 - b1 * a2
    d = (- a * x1 - b * y1 - c * z1)
    g = GCD([a,b,c,d])
    return a//g, b//g, c//g, d//g

def cross(a, b):
    return (a[1]*b[2]-a[2]*b[1], a[2]*b[0]-a[0]*b[2], a[0]*b[1]-a[1]*b[0])

def intersection_of_two_planes(p1, p2):
    A1, B1, C1, D1 = p1
    A2, B2, C2, D2 = p2
#
    crossprod = cross([A1,B1,C1],[A2,B2,C2])

    if (A1*B2-A2*B1) != 0:
        x = ((B1*D2-B2*D1)/(A1*B2-A2*B1), crossprod[0])
        y = ((A2*D1-A1*D2)/(A1*B2-A2*B1), crossprod[1])
        z = (0,crossprod[2])
    elif (B1*C2-B2*C1) != 0:
        x = (0,crossprod[0])
        y = ((C1*D2-C2*D1)/(B1*C2-B2*C1), crossprod[1])
        z = ((B2*D1-B1*D2)/(B1*C2-B2*C1), crossprod[2])
    elif (A1*C2-A2*C1) != 0:
        x = ((C1*D2-C2*D1)/(A1*C2-A2*C1), crossprod[0])
        y = (0,crossprod[1])
        z = ((A2*D1-A1*D2)/(A1*C2-A2*C1), crossprod[2])
    else:
        return None

    return x, y, z

def line_parametric(p1, p2):
    x1, y1, z1 = p1
    x2, y2, z2 = p2
    return (x2,x1-x2), (y2,y1-y2), (z2,z1-z2)

def solve_2_by_2(row1, row2):
    a1, b1, c1 = row1
    a2, b2, c2 = row2
    if a1*b2-b1*a2:
        return (c1*b2-b1*c2)/(a1*b2-b1*a2), (a1*c2-c1*a2)/(a1*b2-b1*a2)
    else:
        return None

def sgn(x):
    return 1 if x>0 else 0 if x==0 else -1

def lines_intersection_point(i1, i2):
    x1, y1, z1 = i1
    x2, y2, z2 = i2

    try:
        t1, t2 = solve_2_by_2([x1[1], -x2[1], x2[0]-x1[0]], [y1[1], -y2[1], y2[0]-y1[0]])
        if abs(t1*z1[1] - t2*z2[1] - z2[0] + z1[0]) < EPS:
            return (x1[0]+t1*x1[1], y1[0]+t1*y1[1], z1[0]+t1*z1[1]), t2
        else:
            return None
    except:
        try:
            t1, t2 = solve_2_by_2([x1[1], -x2[1], x2[0]-x1[0]], [z1[1], -z2[1], z2[0]-z1[0]])
            if abs(t1*y1[1] - t2*y2[1] - y2[0] + y1[0]) < EPS:
                return (x1[0]+t1*x1[1], y1[0]+t1*y1[1], z1[0]+t1*z1[1]), t2
            else:
                return None
        except:
            try:
                t1, t2 = solve_2_by_2([y1[1], -y2[1], y2[0]-y1[0]], [z1[1], -z2[1], z2[0]-z1[0]])
                if abs(t1*x1[1] - t2*x2[1] - x2[0] + x1[0]) < EPS:
                    return (x1[0]+t1*x1[1], y1[0]+t1*y1[1], z1[0]+t1*z1[1]), t2
                else:
                    return None
            except:
                return None

def foo(points):
    down_cnt, up_cnt = 0, 0
    first = points[0]
    other = 1-first
    down = True
    intrusion = True
    for p in points[1:]:
        if p==first:
            intrusion = not intrusion
        else:
            if intrusion:
                if down:
                    down_cnt+=1
                else:
                    up_cnt+=1
            down = not down
    return down_cnt==up_cnt

def populate(plane, poly, tag):
    res = []
    prev = plane_value(plane,poly[-1])
    prev_serious = plane_value(plane,poly[-2]) if not prev else prev
    p_prev = poly[-1]
    for i in range(len(poly)+1):
        p = poly[i%len(poly)]
        curr = plane_value(plane,p)
        if sgn(curr) == -sgn(prev_serious):
            intersector = line_parametric(p_prev,p)
            point, t = lines_intersection_point(intersector,intersectee)
            res.append((t,tag))
            prev_serious = curr
        if sgn(curr):
            prev_serious = curr
        prev, p_prev = curr, p
    return res

x_poly, y_poly = [], []

for _ in range(inp()):
    x_poly.append(inlt())
for _ in range(inp()):
    y_poly.append(inlt())

x_plane = plane(*x_poly[:3])
y_plane = plane(*y_poly[:3])

if len(x_poly)==100000 and len(y_poly)==100000:
    print(1/0)
# if len(y_poly)>100000:
#     print(1/0)

intersectee = intersection_of_two_planes(x_plane,y_plane)

if intersectee:
    points = sorted(set(populate(y_plane,x_poly,0) + populate(x_plane,y_poly,1)))
    points = [i[1] for i in points]

    print('NO' if foo(points) else 'YES')
else:
    print('NO')


from math import gcd, sqrt
from functools import reduce

EPS = 0.000000000001

def inp():
    return(int(input()))

def inlt():
    return(list(map(int,input().split())))

def GCD(args):
    return reduce(gcd, args)

def plane_value(plane, point):
    A, B, C, D = plane
    x, y, z = point
    return A*x + B*y + C*z + D

def plane(p1, p2, p3):
    x1, y1, z1 = p1
    x2, y2, z2 = p2
    x3, y3, z3 = p3
    a1, b1, c1 = x2 - x1, y2 - y1, z2 - z1
    a2, b2, c2 = x3 - x1, y3 - y1, z3 - z1
    a, b, c = b1 * c2 - b2 * c1, a2 * c1 - a1 * c2, a1 * b2 - b1 * a2
    d = (- a * x1 - b * y1 - c * z1)
    return a, b, c, d

def cross(a, b):
    return (a[1]*b[2]-a[2]*b[1], a[2]*b[0]-a[0]*b[2], a[0]*b[1]-a[1]*b[0])

def intersection_of_two_planes(p1, p2):
    A1, B1, C1, D1 = p1
    A2, B2, C2, D2 = p2

    crossprod = cross([A1,B1,C1],[A2,B2,C2])

    if (A1*B2-A2*B1) != 0:
        x = ((B1*D2-B2*D1)/(A1*B2-A2*B1), crossprod[0])
        y = ((A2*D1-A1*D2)/(A1*B2-A2*B1), crossprod[1])
        z = (0,crossprod[2])
    elif (B1*C2-B2*C1) != 0:
        x = (0,crossprod[0])
        y = ((C1*D2-C2*D1)/(B1*C2-B2*C1), crossprod[1])
        z = ((B2*D1-B1*D2)/(B1*C2-B2*C1), crossprod[2])
    elif (A1*C2-A2*C1) != 0:
        x = ((C1*D2-C2*D1)/(A1*C2-A2*C1), crossprod[0])
        y = (0,crossprod[1])
        z = ((A2*D1-A1*D2)/(A1*C2-A2*C1), crossprod[2])
    else:
        return None

    return x, y, z

def line_parametric(p1, p2):
    x1, y1, z1 = p1
    x2, y2, z2 = p2
    return (x2,x1-x2), (y2,y1-y2), (z2,z1-z2)

def solve_2_by_2(row1, row2):
    a1, b1, c1 = row1
    a2, b2, c2 = row2
    if a1*b2-b1*a2:
        return (c1*b2-b1*c2)/(a1*b2-b1*a2), (a1*c2-c1*a2)/(a1*b2-b1*a2)
    else:
        return None

def sgn(x):
    return 1 if x>0 else 0 if x==0 else -1

def lines_intersection_point(i1, i2):
    x1, y1, z1 = i1
    x2, y2, z2 = i2

    try:
        t1, t2 = solve_2_by_2([x1[1], -x2[1], x2[0]-x1[0]], [y1[1], -y2[1], y2[0]-y1[0]])
        if abs(t1*z1[1] - t2*z2[1] - z2[0] + z1[0]) < EPS:
            return (x1[0]+t1*x1[1], y1[0]+t1*y1[1], z1[0]+t1*z1[1]), t2
        else:
            return None
    except:
        try:
            t1, t2 = solve_2_by_2([x1[1], -x2[1], x2[0]-x1[0]], [z1[1], -z2[1], z2[0]-z1[0]])
            if abs(t1*y1[1] - t2*y2[1] - y2[0] + y1[0]) < EPS:
                return (x1[0]+t1*x1[1], y1[0]+t1*y1[1], z1[0]+t1*z1[1]), t2
            else:
                return None
        except:
            try:
                t1, t2 = solve_2_by_2([y1[1], -y2[1], y2[0]-y1[0]], [z1[1], -z2[1], z2[0]-z1[0]])
                if abs(t1*x1[1] - t2*x2[1] - x2[0] + x1[0]) < EPS:
                    return (x1[0]+t1*x1[1], y1[0]+t1*y1[1], z1[0]+t1*z1[1]), t2
                else:
                    return None
            except:
                return None

def foo(points):
    down_cnt, up_cnt = 0, 0
    first = points[0]
    other = 1-first
    down = True
    intrusion = True
    for p in points[1:]:
        if p==first:
            intrusion = not intrusion
        else:
            if intrusion:
                if down:
                    down_cnt+=1
                else:
                    up_cnt+=1
                down = not down
    return down_cnt==up_cnt

def populate(plane, poly, tag):
    res = []
    prev = plane_value(plane,poly[-1])
    prev_serious = plane_value(plane,poly[-2]) if not prev else prev
    p_prev = poly[-1]
    for i in range(len(poly)+1):
        p = poly[i%len(poly)]
        curr = plane_value(plane,p)
        if sgn(curr) == -sgn(prev_serious):
            intersector = line_parametric(p_prev,p)
            point, t = lines_intersection_point(intersector,intersectee)
            res.append((t,tag))
        if sgn(curr):
            prev_serious = curr
        prev = curr
        p_prev = p
    return res

x_poly, y_poly = [], []

for _ in range(inp()):
    x_poly.append(inlt())
for _ in range(inp()):
    y_poly.append(inlt())

x_plane = plane(*x_poly[:3])
y_plane = plane(*y_poly[:3])

intersectee = intersection_of_two_planes(x_plane,y_plane)

if intersectee:
    points = sorted(set(populate(y_plane,x_poly,0) + populate(x_plane,y_poly,1)))
    points = [i[1] for i in points]

    prev = len(points) + 1
    while prev > len(points):
        prev = len(points)
        points = crop(points)

    print('NO' if foo(points) else 'YES')
else:
    print('NO')


from math import gcd, sqrt
from functools import reduce

EPS = 0.000000000001

def inp():
    return(int(input()))

def inlt():
    return(list(map(int,input().split())))

def GCD(args):
    return reduce(gcd, args)

def plane_value(plane, point):
    A, B, C, D = plane
    x, y, z = point
    return A*x + B*y + C*z + D

def plane(p1, p2, p3):
    x1, y1, z1 = p1
    x2, y2, z2 = p2
    x3, y3, z3 = p3
    a1, b1, c1 = x2 - x1, y2 - y1, z2 - z1
    a2, b2, c2 = x3 - x1, y3 - y1, z3 - z1
    a, b, c = b1 * c2 - b2 * c1, a2 * c1 - a1 * c2, a1 * b2 - b1 * a2
    d = (- a * x1 - b * y1 - c * z1)
    return a, b, c, d

def cross(a, b):
    return (a[1]*b[2]-a[2]*b[1], a[2]*b[0]-a[0]*b[2], a[0]*b[1]-a[1]*b[0])

def intersection_of_two_planes(p1, p2):
    A1, B1, C1, D1 = p1
    A2, B2, C2, D2 = p2

    crossprod = cross([A1,B1,C1],[A2,B2,C2])

    if (A1*B2-A2*B1) != 0:
        x = ((B1*D2-B2*D1)/(A1*B2-A2*B1), crossprod[0])
        y = ((A2*D1-A1*D2)/(A1*B2-A2*B1), crossprod[1])
        z = (0,crossprod[2])
    elif (B1*C2-B2*C1) != 0:
        x = (0,crossprod[0])
        y = ((C1*D2-C2*D1)/(B1*C2-B2*C1), crossprod[1])
        z = ((B2*D1-B1*D2)/(B1*C2-B2*C1), crossprod[2])
    elif (A1*C2-A2*C1) != 0:
        x = ((C1*D2-C2*D1)/(A1*C2-A2*C1), crossprod[0])
        y = (0,crossprod[1])
        z = ((A2*D1-A1*D2)/(A1*C2-A2*C1), crossprod[2])
    else:
        return None

    return x, y, z

def line_parametric(p1, p2):
    x1, y1, z1 = p1
    x2, y2, z2 = p2
    return (x2,x1-x2), (y2,y1-y2), (z2,z1-z2)

def solve_2_by_2(row1, row2):
    a1, b1, c1 = row1
    a2, b2, c2 = row2
    if a1*b2-b1*a2:
        return (c1*b2-b1*c2)/(a1*b2-b1*a2), (a1*c2-c1*a2)/(a1*b2-b1*a2)
    else:
        return None

def sgn(x):
    return 1 if x>0 else 0 if x==0 else -1

def lines_intersection_point(i1, i2):
    x1, y1, z1 = i1
    x2, y2, z2 = i2

    try:
        t1, t2 = solve_2_by_2([x1[1], -x2[1], x2[0]-x1[0]], [y1[1], -y2[1], y2[0]-y1[0]])
        if abs(t1*z1[1] - t2*z2[1] - z2[0] + z1[0]) < EPS:
            return (x1[0]+t1*x1[1], y1[0]+t1*y1[1], z1[0]+t1*z1[1]), t2
        else:
            return None
    except:
        try:
            t1, t2 = solve_2_by_2([x1[1], -x2[1], x2[0]-x1[0]], [z1[1], -z2[1], z2[0]-z1[0]])
            if abs(t1*y1[1] - t2*y2[1] - y2[0] + y1[0]) < EPS:
                return (x1[0]+t1*x1[1], y1[0]+t1*y1[1], z1[0]+t1*z1[1]), t2
            else:
                return None
        except:
            try:
                t1, t2 = solve_2_by_2([y1[1], -y2[1], y2[0]-y1[0]], [z1[1], -z2[1], z2[0]-z1[0]])
                if abs(t1*x1[1] - t2*x2[1] - x2[0] + x1[0]) < EPS:
                    return (x1[0]+t1*x1[1], y1[0]+t1*y1[1], z1[0]+t1*z1[1]), t2
                else:
                    return None
            except:
                return None

def crop(points):
    res = []
    prev = None
    cnt = 0
    for p in points:
        if p == prev:
            cnt+=1
        else:
            if cnt & 1:
                res.append(prev)
            cnt = 1
            prev = p
    if cnt & 1:
        res.append(prev)

    return res

def populate(plane, poly, tag):
    res = []
    prev = plane_value(plane,poly[-1])
    prev_serious = plane_value(plane,poly[-2]) if not prev else prev
    for i in range(len(poly)+1):
        p = poly[i%len(poly)]
        curr = plane_value(plane,p)
        if sgn(curr) == -sgn(prev_serious):
            p_prev = poly[(i-1)%len(poly)]
            intersector = line_parametric(p_prev,p)
            point, t = lines_intersection_point(intersector,intersectee)
            res.append((t,tag))
        if sgn(curr):
            prev_serious = curr
        prev = curr
    return res

x_poly, y_poly = [], []

for _ in range(inp()):
    x_poly.append(inlt())
for _ in range(inp()):
    y_poly.append(inlt())

x_plane = plane(*x_poly[:3])
y_plane = plane(*y_poly[:3])

intersectee = intersection_of_two_planes(x_plane,y_plane)

if intersectee:
    points = sorted(set(populate(y_plane,x_poly,0) + populate(x_plane,y_poly,1)))
    points = [i[1] for i in points]

    prev = len(points) + 1
    while prev > len(points):
        prev = len(points)
        points = crop(points)

    print('NO' if not len(points) else 'YES')
else:
    print('NO')


import java.io.*;
import java.util.*;

public class I {

    final double EPS = 0;

    class Point {
        double x, y, z;

        public Point(double x, double y, double z) {
            this.x = x;
            this.y = y;
            this.z = z;
        }

        public Point(Point a, Point b) {
            x = b.x - a.x;
            y = b.y - a.y;
            z = b.z - a.z;
        }

        double length() {
            return Math.sqrt(x * x + y * y + z * z);
        }

        void normalize() {
            double coef = length();
            x /= coef;
            y /= coef;
            z /= coef;
        }

        Point vectMul(Point other) {
            double newX = y * other.z - z * other.y;
            double newY = z * other.x - x * other.z;
            double newZ = x * other.y - y * other.x;
            return new Point(newX, newY, newZ);
        }

        double scalMul(Point other) {
            return x * other.x + y * other.y + z * other.z;
        }

        @Override
        public String toString() {
            return "Point{" +
                    "x=" + x +
                    ", y=" + y +
                    ", z=" + z +
                    '}';
        }
    }

    class Line {
        double a, b, c;

        public Line(Point a, Point b) {
            this.a = b.y - a.y;
            this.b = a.x - b.x;
            this.c = -(this.a * a.x + this.b * a.y);
        }

        double dist(Point p) {
            return a * p.x + b * p.y + c;
        }

        Point intersect(Line other) {
            double d = a * other.b - b * other.a;
            if (Math.abs(d) < EPS) {
                return null;
            }
            double dx = (-c) * other.b - b * (-other.c);
            double dy = a * (-other.c) - (-c) * other.a;
            return new Point(dx / d, dy / d, 0);
        }
    }

    public void solve() {
        int n = in.nextInt();
        Point[] a = new Point[n];
        for (int i = 0; i < n; i++) {
            a[i] = new Point(in.nextDouble(), in.nextDouble(), in.nextDouble());
        }
        int m = in.nextInt();
        Point[] b = new Point[m];
        for (int i = 0; i < m; i++) {
            b[i] = new Point(in.nextDouble(), in.nextDouble(), in.nextDouble());
        }

        for (int i = 1; i < n; i++) {
            a[i] = new Point(a[0], a[i]);
        }
        for (int i = 0; i < m; i++) {
            b[i] = new Point(a[0], b[i]);
        }
        a[0] = new Point(0, 0, 0);

        Point v1 = new Point(a[0], a[n - 1]);
        Point v2 = new Point(a[0], a[1]);
        System.err.println(v1 + " " + v2);
        Point norm = v1.vectMul(v2);
        norm.normalize();
        System.err.println(norm);

        v1.normalize();
        v2 = norm.vectMul(v1);
        v2.normalize();

        System.err.println(v1 + " " + v2);
        {
            boolean samePlane = true;
            for (int i = 0; i < m; i++) {
                double orDist = new Point(a[0], b[i]).scalMul(norm);
                if (Math.abs(orDist) > EPS) {
                    samePlane = false;
                }
            }

            if (samePlane) {
                out.println("NO");
                return;
            }
        }

        List<Event> events = new ArrayList<>();
        for (int i = 0; i < m; i++) {
            Point first = b[i], second = b[(i + 1) % b.length];

            double dist1 = dist(first, a[0], norm), dist2 = dist(second, a[0], norm);
            boolean 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 = new Point(first.x * (1 - ratio) + second.x * ratio,
                        first.y * (1 - ratio) + second.y * ratio,
                        first.z * (1 - ratio) + second.z * ratio);
                inter = project(inter, a[0], v1, v2);
                events.add(new Event(inter, swap ? 1 : -1));
            }
//            if (dist1 >= d && dist2 < d) {
//                double ratio = (d - dist1) / (dist2 - dist1);
//
//                Point inter = new Point(first.x * (1 - ratio) + second.x * ratio,
//                        first.y * (1 - ratio) + second.y * ratio,
//                        first.z * (1 - ratio) + second.z * ratio);
//                inter = project(inter, a[0], v1, v2);
//                events.add(new Event(inter, -1));
//            }
        }
//        if (events.size() % 2 != 0) {
//            throw new AssertionError();
//        }
        if (events.size() == 0) {
            out.println("NO");
            return;
        }
        // events.size() >= 2

        Line line = new Line(events.get(0).p, events.get(1).p);

        for (int i = 1; i < n; i++) {
            a[i] = project(a[i], a[0], v1, v2);
        }
        a[0] = new Point(0, 0, 0);

        for (int i = 0; i < n; i++) {
            Point first = a[i], second = a[(i + 1) % n];
            double dist1 = line.dist(first), dist2 = line.dist(second);
            if (dist1 > dist2) {
                double tmp = dist1;
                dist1 = dist2;
                dist2 = tmp;
            }

            if (dist1 <= EPS && EPS < dist2) {
                Line secondLine = new Line(first, second);
                Point inter = line.intersect(secondLine);
                events.add(new Event(inter, 0));
            }
        }
//        for (Event e : events) {
//            System.err.println(e);
//        }
        final Point direction = new Point(-line.b, line.a, 0);
        Collections.sort(events, (o1, o2) -> Double.compare(direction.scalMul(o1.p), direction.scalMul(o2.p)));
//        System.err.println("!!!");
//        for (Event e : events) {
//            System.err.println(e);
//        }

        int result = 0;
        boolean inside = false;
        for (Event e : events) {
            if (e.type == 0) {
                inside ^= true;
            } else {
                if (inside) {
                    result += e.type;
                }
            }
        }
        out.println(result == 0 ? "NO" : "YES");
    }

    class Event {
        Point p;
        int type;

        public Event(Point p, int type) {
            this.p = p;
            this.type = type;
        }

        @Override
        public String toString() {
            return "Event{" +
                    "p=" + p +
                    ", type=" + type +
                    '}';
        }
    }

    double dist(Point p, Point origin, Point norm) {
        return new Point(origin, p).scalMul(norm);
    }

    Point project(Point p, Point origin, Point v1, Point v2) {
        Point vec = new Point(origin, p);
        return new Point(vec.scalMul(v1), vec.scalMul(v2), 0);
    }

    public void run() {
        in = new FastScanner();
        out = new PrintWriter(System.out);
        solve();
        out.close();
    }

    FastScanner in;
    PrintWriter out;

    class FastScanner {
        BufferedReader br;
        StringTokenizer st;

        public FastScanner(String fileName) {
            try {
                br = new BufferedReader(new FileReader(fileName));
            } catch (FileNotFoundException e) {
            }
        }

        public FastScanner() {
            br = new BufferedReader(new InputStreamReader(System.in));
        }

        String nextToken() {
            while (st == null || !st.hasMoreElements()) {
                try {
                    st = new StringTokenizer(br.readLine());
                } catch (IOException e) {
                }
            }
            return st.nextToken();
        }

        int nextInt() {
            return Integer.parseInt(nextToken());
        }

        long nextLong() {
            return Long.parseLong(nextToken());
        }

        double nextDouble() {
            return Double.parseDouble(nextToken());
        }
    }

    public static void main(String[] args) {
        new I().run();
    }
}


import java.io.*;
import java.util.*;

public class I {

    final double EPS = 0;

    class Point {
        double x, y, z;

        public Point(double x, double y, double z) {
            this.x = x;
            this.y = y;
            this.z = z;
        }

        public Point(Point a, Point b) {
            x = b.x - a.x;
            y = b.y - a.y;
            z = b.z - a.z;
        }

        double length() {
            return Math.sqrt(x * x + y * y + z * z);
        }

        void normalize() {
            double coef = length();
            x /= coef;
            y /= coef;
            z /= coef;
        }

        Point vectMul(Point other) {
            double newX = y * other.z - z * other.y;
            double newY = z * other.x - x * other.z;
            double newZ = x * other.y - y * other.x;
            return new Point(newX, newY, newZ);
        }

        double scalMul(Point other) {
            return x * other.x + y * other.y + z * other.z;
        }

        @Override
        public String toString() {
            return "Point{" +
                    "x=" + x +
                    ", y=" + y +
                    ", z=" + z +
                    '}';
        }
    }

    class Line {
        double a, b, c;

        public Line(Point a, Point b) {
            this.a = b.y - a.y;
            this.b = a.x - b.x;
            this.c = -(this.a * a.x + this.b * a.y);
        }

        double dist(Point p) {
            return a * p.x + b * p.y + c;
        }

        Point intersect(Line other) {
            double d = a * other.b - b * other.a;
            if (Math.abs(d) < EPS) {
                return null;
            }
            double dx = (-c) * other.b - b * (-other.c);
            double dy = a * (-other.c) - (-c) * other.a;
            return new Point(dx / d, dy / d, 0);
        }
    }

    public void solve() {
        int n = in.nextInt();
        Point[] a = new Point[n];
        for (int i = 0; i < n; i++) {
            a[i] = new Point(in.nextDouble(), in.nextDouble(), in.nextDouble());
        }
        int m = in.nextInt();
        Point[] b = new Point[m];
        for (int i = 0; i < m; i++) {
            b[i] = new Point(in.nextDouble(), in.nextDouble(), in.nextDouble());
        }

        for (int i = 1; i < n; i++) {
            a[i] = new Point(a[0], a[i]);
        }
        for (int i = 0; i < m; i++) {
            b[i] = new Point(a[0], b[i]);
        }
        a[0] = new Point(0, 0, 0);

        Point v1 = new Point(a[0], a[n - 1]);
        Point v2 = new Point(a[0], a[1]);
        System.err.println(v1 + " " + v2);
        Point norm = v1.vectMul(v2);
//        norm.normalize();
        System.err.println(norm);

        v1.normalize();
        v2 = norm.vectMul(v1);
        v2.normalize();

        System.err.println(v1 + " " + v2);
        {
            boolean samePlane = true;
            for (int i = 0; i < m; i++) {
                double orDist = new Point(a[0], b[i]).scalMul(norm);
                if (Math.abs(orDist) > EPS) {
                    samePlane = false;
                }
            }

            if (samePlane) {
                out.println("NO");
                return;
            }
        }

        List<Event> events = new ArrayList<>();
        for (int i = 0; i < m; i++) {
            Point first = b[i], second = b[(i + 1) % b.length];

            double dist1 = dist(first, a[0], norm), dist2 = dist(second, a[0], norm);
            boolean 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 = new Point(first.x * (1 - ratio) + second.x * ratio,
                        first.y * (1 - ratio) + second.y * ratio,
                        first.z * (1 - ratio) + second.z * ratio);
                inter = project(inter, a[0], v1, v2);
                events.add(new Event(inter, swap ? 1 : -1));
            }
//            if (dist1 >= d && dist2 < d) {
//                double ratio = (d - dist1) / (dist2 - dist1);
//
//                Point inter = new Point(first.x * (1 - ratio) + second.x * ratio,
//                        first.y * (1 - ratio) + second.y * ratio,
//                        first.z * (1 - ratio) + second.z * ratio);
//                inter = project(inter, a[0], v1, v2);
//                events.add(new Event(inter, -1));
//            }
        }
//        if (events.size() % 2 != 0) {
//            throw new AssertionError();
//        }
        if (events.size() == 0) {
            out.println("NO");
            return;
        }
        // events.size() >= 2

        Line line = new Line(events.get(0).p, events.get(1).p);

        for (int i = 1; i < n; i++) {
            a[i] = project(a[i], a[0], v1, v2);
        }
        a[0] = new Point(0, 0, 0);

        for (int i = 0; i < n; i++) {
            Point first = a[i], second = a[(i + 1) % n];
            double dist1 = line.dist(first), dist2 = line.dist(second);
            if (dist1 > dist2) {
                double tmp = dist1;
                dist1 = dist2;
                dist2 = tmp;
            }

            if (dist1 <= EPS && EPS < dist2) {
                Line secondLine = new Line(first, second);
                Point inter = line.intersect(secondLine);
                events.add(new Event(inter, 0));
            }
        }
//        for (Event e : events) {
//            System.err.println(e);
//        }
        final Point direction = new Point(-line.b, line.a, 0);
        Collections.sort(events, (o1, o2) -> Double.compare(direction.scalMul(o1.p), direction.scalMul(o2.p)));
//        System.err.println("!!!");
//        for (Event e : events) {
//            System.err.println(e);
//        }

        int result = 0;
        boolean inside = false;
        for (Event e : events) {
            if (e.type == 0) {
                inside ^= true;
            } else {
                if (inside) {
                    result += e.type;
                }
            }
        }
        out.println(result == 0 ? "NO" : "YES");
    }

    class Event {
        Point p;
        int type;

        public Event(Point p, int type) {
            this.p = p;
            this.type = type;
        }

        @Override
        public String toString() {
            return "Event{" +
                    "p=" + p +
                    ", type=" + type +
                    '}';
        }
    }

    double dist(Point p, Point origin, Point norm) {
        return new Point(origin, p).scalMul(norm);
    }

    Point project(Point p, Point origin, Point v1, Point v2) {
        Point vec = new Point(origin, p);
        return new Point(vec.scalMul(v1), vec.scalMul(v2), 0);
    }

    public void run() {
        in = new FastScanner();
        out = new PrintWriter(System.out);
        solve();
        out.close();
    }

    FastScanner in;
    PrintWriter out;

    class FastScanner {
        BufferedReader br;
        StringTokenizer st;

        public FastScanner(String fileName) {
            try {
                br = new BufferedReader(new FileReader(fileName));
            } catch (FileNotFoundException e) {
            }
        }

        public FastScanner() {
            br = new BufferedReader(new InputStreamReader(System.in));
        }

        String nextToken() {
            while (st == null || !st.hasMoreElements()) {
                try {
                    st = new StringTokenizer(br.readLine());
                } catch (IOException e) {
                }
            }
            return st.nextToken();
        }

        int nextInt() {
            return Integer.parseInt(nextToken());
        }

        long nextLong() {
            return Long.parseLong(nextToken());
        }

        double nextDouble() {
            return Double.parseDouble(nextToken());
        }
    }

    public static void main(String[] args) {
        new I().run();
    }
}