import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; public class Main{ public static void main(String[] args)throws IOException{ BufferedReader in = new BufferedReader(new InputStreamReader(System.in)); String input; while((input = in.readLine()) != null){ String[] s = input.split(" "); int m = Integer.parseInt(s[0]); int n = Integer.parseInt(s[1]); System.out.println(req1(m,n)); s=in.readLine().split(" "); int x1 = Integer.parseInt(s[0]); int y1 = Integer.parseInt(s[1]); int x2 = Integer.parseInt(s[2]); int y2 = Integer.parseInt(s[3]);

            System.out.println(req2(m,n,x1,y1,x2,y2));
            

        
        int insrow = Integer.parseInt(in.readLine());
        System.out.println(insertrow(m,insrow));
        int inscol = Integer.parseInt(in.readLine());
        System.out.println(insertcol(n,inscol));
        s=in.readLine().split(" ");
        int x = Integer.parseInt(s[0]);
        int y = Integer.parseInt(s[1]);
   
             System.out.println(query(m,n,x,y));
            

       
    }
}
public static int query(int m,int n,int x,int y){
     int canery = -1;
    if(x < m && x >=0 &&
       y < n && y >=0 
      ){
        canery = 0;
    }
    return canery;
}
public static int insertcol(int n,int inscol){
    int canery = -1;
    if(n +1 <= 9 && inscol >=0 && inscol < n){
        canery = 0;
    }
    return canery;
}
public static int insertrow(int m,int insrow){
    int canery = -1;
    if(m +1 <= 9 && insrow >=0 && insrow < m){
        canery = 0;
    }
    return canery;
}
public static int req1(int m,int n){
    int canery = -1;
    if(m <= 9 && m > 0 && n <= 9 && n > 0){
        canery = 0;
    }
    return canery;
}
public static int req2(int m,int n,int x1,int y1,int x2,int y2){
    int canery = -1;
    if(x1 < m && x1 >= 0 &&
       y1 < n && y1 >= 0 &&
       x2 < m && x2 >= 0 &&
       y2 < n && y2 >= 0 
      ){
                canery = 0;
            }
    return canery;
}

}