import java.util.Scanner;
public class Main {
public static void main(String[] args) {
Scanner in = new Scanner(System.in);
// 注意 hasNext 和 hasNextLine 的区别
while (in.hasNextInt()) { // 注意 while 处理多个 case
int m = in.nextInt();
int n = in.nextInt();
int[][] a = new int[m][n];
System.out.println((m>9 || n>9)?-1:0);
int x1 = in.nextInt();
int y1 = in.nextInt();
int x2 = in.nextInt();
int y2 = in.nextInt();
System.out.println(((Math.max(x1,x2)>=m) || (Math.max(y1,y2)>=n))?-1:0);
int x = in.nextInt();
System.out.println((x>=m || (m+1)>9)?-1:0);
int y = in.nextInt();
System.out.println((y>=n || (n+1)>9)?-1:0);
x = in.nextInt();
y = in.nextInt();
System.out.println((x>=m || y>=n)?-1:0);
}
}
}