#include<stdio.h>
int main()
{
int m, n, x1, y1, x2, y2, x, y, a, b;
while(scanf("%d %d", &m, &n) != EOF)
{
scanf("%d %d %d %d", &x1, &y1, &x2, &y2);
scanf("%d", &x);
scanf("%d", &y);
scanf("%d %d", &a, &b);
//判断初始化数据表是否成功
if(m <= 9 && n <= 9)
printf("0\n");
else
printf("-1\n");
//判断交换单元格是否成功
if(x1>=0 && x1<=m-1 && x2>=0 && x2<=m-1 && y1>=0 && y1<=n-1 && y2>=0 && y2<=n-1)
printf("0\n");
else
printf("-1\n");
//判断插入行是否成功
if(m+1<=9 && x<m)
printf("0\n");
else
printf("-1\n");
//判断插入列是否成功
if(n+1<=9 && y<n)
printf("0\n");
else
printf("-1\n");
//判断查询单元格数据是否成功
if(a>=0 && a<=m-1 && b>=0 && b<=n-1)
printf("0\n");
else
printf("-1\n");
}
return 0;
}