import java.util.*;

public class Main{

public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    while(sc.hasNext()){
        int m = sc.nextInt(), n = sc.nextInt();
        int x1 = sc.nextInt(), y1 = sc.nextInt(), x2 = sc.nextInt(), y2 = sc.nextInt();
        //要插入的行
        int x = sc.nextInt();
        //要插入的列
        int y = sc.nextInt();
        //插入坐标
        int xAxis = sc.nextInt(), yAxis = sc.nextInt();
        if(m <= 9 && n <= 9) System.out.println(0);
        else System.out.println(-1);
        if(x1 < m && y1 < n && x2 < m && y2 < n) System.out.println(0);
        else System.out.println(-1);
        if(m + 1 <= 9 && x < m) System.out.println(0);
        else System.out.println(-1);
        if(n + 1 <= 9 && y < n) System.out.println(0);
        else System.out.println(-1);
        if(xAxis < m && yAxis < n) System.out.println(0);
        else System.out.println(-1);
    }
}

}