#include<iostream> using namespace std; int main(){ int m,n; while(cin >> m >> n){ if(m > 9 || n > 9) cout << -1 << endl; else cout << 0 << endl; int x1,y1,x2,y2; cin >> x1 >> y1 >> x2 >> y2; if(x1 < 0 || y1 < 0 || x2 < 0 || y2 < 0) cout << -1 << endl; else if((x1 >= m || y1 >= n || x2 >= m || y2 >= n)) cout << -1 << endl; else cout << 0 << endl; int x, y; cin >> x; if(x < 0 || x >= m || m == 9){ cout << -1 << endl; }else cout << 0 << endl; cin >> y; if(y < 0 || y >= n || n == 9){ cout << -1 << endl; }else cout << 0 << endl; cin >> x >> y; if((x >= m || y >= n || x < 0 || y < 0)){ cout << -1 << endl; }else cout << 0 << endl; } return 0; }