#include<stdio.h>
int main(){
int m,n,x1,y1,x2,y2,x,y,x0,y0;
while(~scanf("%d %d",&m,&n)){
scanf("%d%d%d%d%d%d%d%d",&x1,&y1,&x2,&y2,&x,&y,&x0,&y0);
printf("%d\n",m>=1&&m<=9&&n>=1&&n<=9?0:-1);
printf("%d\n",x1>=0&&x1<=m-1&&
y1>=0&&y1<=n-1&&
x2>=0&&x2<=m-1&&
y2>=0&&y2<=n-1 ? 0 : -1);
printf("%d\n",m>=1&&m<=8&&x>=0&&x<=m-1?0:-1);
printf("%d\n",n>=1&&n<=8&&y>=0&&y<=n-1?0:-1);
printf("%d\n",x0>=0&&x0<=m-1&&
y0>=0&&y0<=n-1 ? 0 : -1);
}
}