#include <iostream>
using namespace std;

int main() {
    int row;//行
    int column;//列
    int swap_x1;
    int swap_y1;
    int swap_x2;
    int swap_y2;
    int insert_row;
    int insert_column;
    int x_find;
    int y_find;
    while (cin >> row >> column >> swap_x1 >> swap_y1 >> swap_x2 >> swap_y2 >>
           insert_row >> insert_column >> x_find >> y_find){
        if((row >= 0 && row <= 9) && (column >= 0 && column <= 9)){//判断初始化
            cout << 0 << endl;
        }
        else cout << -1 << endl;
        
        if((swap_x1 <= (row-1) && swap_y1 <= (column-1)) && ((swap_x2 <= (row-1) && swap_y2 <= (column-1)))){//判断交换
            cout << 0 << endl;
        }
        else cout << -1 << endl;
           
        if((insert_row <= (row-1) && row < 9)){//判断插入行
            cout << 0 << endl;
        }
        else cout << -1 << endl;
           
        if((insert_column <= (column-1) && column < 9)){//判断插入列
            cout << 0 << endl;
        }
        else cout << -1 << endl;
           
        if((x_find <= (row-1) && y_find <= (column-1))){//判断查询
            cout << 0 << endl;
        }
        else cout << -1 << endl;
    }


}