// Arup Guha
// 11/11/2017
// Solution to 2017 SER D2 Problem: Law 11

import java.util.*;

public class law11 {

	public static pt ball;
	public static pt[] offense;
	public static pt[] defense;

	public static void main(String[] args) {

		// Get the ball.
		Scanner stdin = new Scanner(System.in);
		int x = stdin.nextInt();
		int y = stdin.nextInt();
		ball = new pt(x,y);

		// The offense - sort it.
		offense = new pt[11];
		for (int i=0; i<11; i++) {
			x = stdin.nextInt();
			y = stdin.nextInt();
			offense[i] = new pt(x,y);
		}
		Arrays.sort(offense);

		// Do the same for the defense.
		defense = new pt[11];
		for (int i=0; i<11; i++) {
			x = stdin.nextInt();
			y = stdin.nextInt();
			defense[i] = new pt(x,y);
		}
		Arrays.sort(defense);

		// Most forward offensive player.
		pt forward = offense[10];
		pt defender = defense[9];

		// This is how we become offsides (past ball, past defender, past midway)
		if (forward.compareTo(ball) > 0 && forward.compareTo(defender) > 0 && forward.x > 0)
			System.out.println(1);
		else
			System.out.println(0);
	}
}

class pt implements Comparable<pt> {

	public int x;
	public int y;

	public pt(int myx, int myy) {
		x = myx;
		y = myy;
	}

	public int compareTo(pt other) {
		return this.x-other.x;
	}
}