public static void main(String[] args) throws IOException {
		BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
		StringBuilder out = new StringBuilder();
		String line = "";
		while ((line = in.readLine()) != null && line.length() != 0) {
			double xm = Double.parseDouble(line.trim());
			double ym = Double.parseDouble(in.readLine().trim());
			Point m = new Point(xm, ym);
			int n = Integer.parseInt(in.readLine().trim());
			Point[] s = new Point[n + 1];
			for (int i = 0; i < n + 1; i++) {
				double x = Double.parseDouble(in.readLine().trim());
				double y = Double.parseDouble(in.readLine().trim());
				s[i] = new Point(x, y);
			}
			double dis = Double.MAX_VALUE, d;
			Point ans = new Point(0, 0);
			for (int i = 1; i < n + 1; i++) {
				Point per = minPointSeg(s[i - 1], s[i], m);
				d = dis(per, m);
				if (d < dis) {
					dis = d;
					ans = per;
				}
			}
			out.append(f(ans.x) + "\n" + f(ans.y) + "\n");
		}
		System.out.print(out);
	}