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

public class Validate {

	final int MAX = 100;
	final int MAX_N = 50;

	class Point {
		int x, y;

		public Point(int x, int y) {
			super();
			this.x = x;
			this.y = y;
		}

	}

	int gcd(int x, int y) {
		return x == 0 ? y : gcd(y % x, x);
	}

	class Line {
		int A, B, C;

		Line(Point from, Point to) {
			A = to.y - from.y;
			B = from.x - to.x;
			C = -(A * from.x + B * from.y);
			int g = gcd(gcd(Math.abs(A), Math.abs(B)), Math.abs(C));
			A /= g;
			B /= g;
			C /= g;
			if (A < 0) {
				A *= -1;
				B *= -1;
				C *= -1;
			} else {
				if (A == 0) {
					if (B < 0) {
						A *= -1;
						B *= -1;
						C *= -1;
					} else {
						if (B == 0) {
							if (C < 0) {
								A *= -1;
								B *= -1;
								C *= -1;
							}
						}
					}
				}
			}
		}

		@Override
		public int hashCode() {
			final int prime = 31;
			int result = 1;
			result = prime * result + getOuterType().hashCode();
			result = prime * result + A;
			result = prime * result + B;
			result = prime * result + C;
			return result;
		}

		@Override
		public boolean equals(Object obj) {
			if (this == obj)
				return true;
			if (obj == null)
				return false;
			if (getClass() != obj.getClass())
				return false;
			Line other = (Line) obj;
			if (!getOuterType().equals(other.getOuterType()))
				return false;
			if (A != other.A)
				return false;
			if (B != other.B)
				return false;
			if (C != other.C)
				return false;
			return true;
		}

		private Validate getOuterType() {
			return Validate.this;
		}

	}

	public void run() {
		StrictScanner inf = new StrictScanner(System.in);
		int n = inf.nextInt();
		ensureLimits(n, 1, MAX_N, "number of lines");
		inf.nextLine();
		HashSet<Line> allLines = new HashSet<>();
		for (int i = 0; i < n; i++) {
			int x1 = inf.nextInt(), y1 = inf.nextInt(), x2 = inf.nextInt(), y2 = inf
					.nextInt();
			inf.nextLine();
			ensureLimits(x1, -MAX, MAX, "x1");
			ensureLimits(y1, -MAX, MAX, "y1");
			ensureLimits(x2, -MAX, MAX, "x2");
			ensureLimits(y2, -MAX, MAX, "y2");
			ensure(x1 != x2 || y1 != y2, "same points");
			Line l = new Line(new Point(x1, y1), new Point(x2, y2));
			ensure(!allLines.contains(l), "same lines");
			allLines.add(l);
		}
		int x1 = inf.nextInt(), y1 = inf.nextInt();
		inf.nextLine();
		int x2 = inf.nextInt(), y2 = inf.nextInt();
		inf.nextLine();
		ensureLimits(x1, -MAX, MAX, "start_x");
		ensureLimits(y1, -MAX, MAX, "start_y");
		ensureLimits(x2, -MAX, MAX, "end_x");
		ensureLimits(y2, -MAX, MAX, "end_y");
		int[] cnt = new int[2];
		for (Line l : allLines) {
			if (l.A * x1 + l.B * y1 + l.C == 0) {
				cnt[0]++;
			}
			if (l.A * x2 + l.B * y2 + l.C == 0) {
				cnt[1]++;
			}
		}
		ensure(cnt[0] == 1 && cnt[1] == 1,
				"start and end points should lie exectly on one line");
		inf.close();
	}

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

	public class StrictScanner {
		private final BufferedReader in;
		private String line = "";
		private int pos;
		private int lineNo;

		public StrictScanner(InputStream source) {
			in = new BufferedReader(new InputStreamReader(source));
			nextLine();
		}

		public void close() {
			ensure(line == null, "Extra data at the end of file");
			try {
				in.close();
			} catch (IOException e) {
				throw new AssertionError("Failed to close with " + e);
			}
		}

		public void nextLine() {
			ensure(line != null, "EOF");
			ensure(pos == line.length(), "Extra characters on line " + lineNo);
			try {
				line = in.readLine();
			} catch (IOException e) {
				throw new AssertionError("Failed to read line with " + e);
			}
			pos = 0;
			lineNo++;
		}

		public String next() {
			ensure(line != null, "EOF");
			ensure(line.length() > 0, "Empty line " + lineNo);
			if (pos == 0)
				ensure(line.charAt(0) > ' ', "Line " + lineNo
						+ " starts with whitespace");
			else {
				ensure(pos < line.length(), "Line " + lineNo + " is over");
				ensure(line.charAt(pos) == ' ', "Wrong whitespace on line "
						+ lineNo);
				pos++;
				ensure(pos < line.length(), "Line " + lineNo + " is over");
				ensure(line.charAt(0) > ' ', "Line " + lineNo
						+ " has double whitespace");
			}
			StringBuilder sb = new StringBuilder();
			while (pos < line.length() && line.charAt(pos) > ' ')
				sb.append(line.charAt(pos++));
			return sb.toString();
		}

		public int nextInt() {
			String s = next();
			ensure(s.length() == 1 || s.charAt(0) != '0',
					"Extra leading zero in number " + s + " on line " + lineNo);
			ensure(s.charAt(0) != '+', "Extra leading '+' in number " + s
					+ " on line " + lineNo);
			try {
				return Integer.parseInt(s);
			} catch (NumberFormatException e) {
				throw new AssertionError("Malformed number " + s + " on line "
						+ lineNo);
			}
		}

		public long nextLong() {
			String s = next();
			ensure(s.length() == 1 || s.charAt(0) != '0',
					"Extra leading zero in number " + s + " on line " + lineNo);
			ensure(s.charAt(0) != '+', "Extra leading '+' in number " + s
					+ " on line " + lineNo);
			try {
				return Long.parseLong(s);
			} catch (NumberFormatException e) {
				throw new AssertionError("Malformed number " + s + " on line "
						+ lineNo);
			}
		}

		public double nextDouble() {
			String s = next();
			ensure(s.length() == 1 || s.startsWith("0.") || s.charAt(0) != '0',
					"Extra leading zero in number " + s + " on line " + lineNo);
			ensure(s.charAt(0) != '+', "Extra leading '+' in number " + s
					+ " on line " + lineNo);
			try {
				return Double.parseDouble(s);
			} catch (NumberFormatException e) {
				throw new AssertionError("Malformed number " + s + " on line "
						+ lineNo);
			}
		}
	}

	void ensure(boolean b, String message) {
		if (!b) {
			throw new AssertionError(message);
		}
	}

	void ensureLimits(long n, long from, long to, String name) {
		ensure(from <= n && n <= to, name + " must be from " + from + " to "
				+ to);
	}

	void ensureLimits(int n, int from, int to, String name) {
		ensure(from <= n && n <= to, name + " must be from " + from + " to "
				+ to);
	}

	void ensureString(String s, String alph, String text) {
		for (int i = 0; i < s.length(); i++) {
			ensure(alph.indexOf(s.charAt(i)) != -1, text);
		}
	}

}