#include <stdio.h> #include <stdbool.h> bool checkvalid(int m, int n, int x, int y) { return ((x >= 0) && (x <= m - 1) && (y >= 0) && (y <= n - 1)); } int main() { int m, n, x1, y1, x2, y2, x, y; while (scanf("%d %d", &m, &n) != EOF) { if((m > 0) && (m <= 9) && (n > 0) && (n <= 9)) printf("0\n"); else printf("-1\n"); scanf("%d %d %d %d", &x1, &y1, &x2, &y2); if(checkvalid(m, n, x1, y1) && checkvalid(m, n, x2, y2)) printf("0\n"); else printf("-1\n"); scanf("%d", &x); if(m > 0 && m < 9 && m > x) printf("0\n"); else printf("-1\n"); scanf("%d", &y); if(n > 0 && n < 9 && n > y) printf("0\n"); else printf("-1\n"); scanf("%d %d", &x, &y); if(checkvalid(m, n, x, y)) printf("0\n"); else printf("-1\n"); } return 0; }