#include #include using namespace std; bool isPoint(int x1, int y1, int x2, int y2, int x3, int y3, int x4, int y4) { if( ((x1==x3)&&(y1==y3)) || ((x1==x3)&&(y2==y4)) || ((x2==x4)&&(y1==y3)) || ((x2==x4)&&(y2==y4))) { return true; } if( ((x1==x4)&&(y1==y4)) || ((x1==x3)&&(y2==y3)) || ((x2==x3)&&(y2==y3)) || ((x2==x4)&&(y1==y4))) { return true; } return false; } bool isLine(int x1, int y1, int x2, int y2, int x3, int y3, int x4, int y4) { int l = 0; if(x2>x1) { for(int x=x1;x<=x2;x++) { if(x4>x3) { for(int xx=x3;xx<=x4;xx++) { if( (xx==x)&&(y3==y1) || (xx==x)&&(y4==y1) || (xx==x)&&(y3==y2) || (xx==x)&&(y4==y2)) { l++; } } } else { for(int xx=x4;xx<=x3;xx++) { if( (xx==x)&&(y3==y1) || (xx==x)&&(y4==y1) || (xx==x)&&(y3==y2) || (xx==x)&&(y4==y2)) { l++; } } } if(l==2) return true; } } else { for(int x=x2;x<=x1;x++) { if(x4>x3) { for(int xx=x3;xx<=x4;xx++) { if( (xx==x)&&(y3==y1) || (xx==x)&&(y4==y1) || (xx==x)&&(y3==y2) || (xx==x)&&(y4==y2)) { l++; } } } else { for(int xx=x4;xx<=x3;xx++) { if( (xx==x)&&(y3==y1) || (xx==x)&&(y4==y1) || (xx==x)&&(y3==y2) || (xx==x)&&(y4==y2)) { l++; } } } if(l==2) return true; } } l=0; if(y2>y1) { for(int y=y1;y<=y2;y++) { if(y4>y3) { for(int yy=y3;yy<=y4;yy++) { if( (yy==y)&&(x3==x1) || (yy==y)&&(x4==x1) || (yy==y)&&(x3==x2) || (yy==y)&&(x4==x2)) { l++; } } } else { for(int yy=y4;yy<=y3;yy++) { if( (yy==y)&&(x3==x1) || (yy==y)&&(x4==x1) || (yy==y)&&(x3==x2) || (yy==y)&&(x4==x2)) { l++; } } } if(l==2) return true; } } else { for(int y=y2;y<=y1;y++) { if(y4>y3) { for(int yy=y3;yy<=y4;yy++) { if( (yy==y)&&(x3==x1) || (yy==y)&&(x4==x1) || (yy==y)&&(x3==x2) || (yy==y)&&(x4==x2)) { l++; } } } else { for(int yy=y4;yy<=y3;yy++) { if( (yy==y)&&(x3==x1) || (yy==y)&&(x4==x1) || (yy==y)&&(x3==x2) || (yy==y)&&(x4==x2)) { l++; } } } if(l==2) return true; } } return false; } bool isRectangle(int x1, int y1, int x2, int y2, int x3, int y3, int x4, int y4) { if(x2>x1) { for(int x=x1+1;xy1) { for(int y=y1+1;yy1) { for(int y=y1+1;yx1) { for(int x=x1;x<=x2;x++) { if(x4>x3) { for(int xx=x3;xx<=x4;xx++) { if((xx==x)&&(y3==y1)) { if(y4>y3) { for(int yyy=y1+1;yyy<=y4;yyy++) { if(yyy==y2) { return true; } } } else { for(int yyy=y1+1;yyy<=y3;yyy++) { if(yyy==y2) { return true; } } } } if((xx==x)&&(y4==y1)) { if(y4>y3) { for(int yyy=y1+1;yyy<=y4;yyy++) { if(yyy==y2) { return true; } } } else { for(int yyy=y1+1;yyy<=y3;yyy++) { if(yyy==y2) { return true; } } } } if((xx==x)&&(y3==y2)) { if(y4>y3) { for(int yyy=y2-1;yyy<=y4;yyy++) { if(yyy==y1) { return true; } } } else { for(int yyy=y2-1;yyy<=y3;yyy++) { if(yyy==y1) { return true; } } } } if((xx==x)&&(y4==y2)) { if(y4>y3) { for(int yyy=y2-1;yyy<=y4;yyy++) { if(yyy==y1) { return true; } } } else { for(int yyy=y2-1;yyy<=y3;yyy++) { if(yyy==y1) { return true; } } } } } } else { for(int xx=x4;xx<=x3;xx++) { if((xx==x)&&(y3==y1)) { if(y4>y3) { for(int yyy=y1+1;yyy<=y4;yyy++) { if(yyy==y2) { return true; } } } else { for(int yyy=y1+1;yyy<=y3;yyy++) { if(yyy==y2) { return true; } } } } if((xx==x)&&(y4==y1)) { if(y4>y3) { for(int yyy=y1+1;yyy<=y4;yyy++) { if(yyy==y2) { return true; } } } else { for(int yyy=y1+1;yyy<=y3;yyy++) { if(yyy==y2) { return true; } } } } if((xx==x)&&(y3==y2)) { if(y4>y3) { for(int yyy=y2-1;yyy<=y4;yyy++) { if(yyy==y1) { return true; } } } else { for(int yyy=y2-1;yyy<=y3;yyy++) { if(yyy==y1) { return true; } } } } if((xx==x)&&(y4==y2)) { if(y4>y3) { for(int yyy=y2-1;yyy<=y4;yyy++) { if(yyy==y1) { return true; } } } else { for(int yyy=y2-1;yyy<=y3;yyy++) { if(yyy==y1) { return true; } } } } } } } } else { for(int x=x2;x<=x1;x++) { if(x4>x3) { for(int xx=x3;xx<=x4;xx++) { if((xx==x)&&(y3==y1)) { if(y4>y3) { for(int yyy=y1+1;yyy<=y4;yyy++) { if(yyy==y2) { return true; } } } else { for(int yyy=y1+1;yyy<=y3;yyy++) { if(yyy==y2) { return true; } } } } if((xx==x)&&(y4==y1)) { if(y4>y3) { for(int yyy=y1+1;yyy<=y4;yyy++) { if(yyy==y2) { return true; } } } else { for(int yyy=y1+1;yyy<=y3;yyy++) { if(yyy==y2) { return true; } } } } if((xx==x)&&(y3==y2)) { if(y4>y3) { for(int yyy=y2-1;yyy<=y4;yyy++) { if(yyy==y1) { return true; } } } else { for(int yyy=y2-1;yyy<=y3;yyy++) { if(yyy==y1) { return true; } } } } if((xx==x)&&(y4==y2)) { if(y4>y3) { for(int yyy=y2-1;yyy<=y4;yyy++) { if(yyy==y1) { return true; } } } else { for(int yyy=y2-1;yyy<=y3;yyy++) { if(yyy==y1) { return true; } } } } } } else { for(int xx=x4;xx<=x3;xx++) { if((xx==x)&&(y3==y1)) { if(y4>y3) { for(int yyy=y1+1;yyy<=y4;yyy++) { if(yyy==y2) { return true; } } } else { for(int yyy=y1+1;yyy<=y3;yyy++) { if(yyy==y2) { return true; } } } } if((xx==x)&&(y4==y1)) { if(y4>y3) { for(int yyy=y1+1;yyy<=y4;yyy++) { if(yyy==y2) { return true; } } } else { for(int yyy=y1+1;yyy<=y3;yyy++) { if(yyy==y2) { return true; } } } } if((xx==x)&&(y3==y2)) { if(y4>y3) { for(int yyy=y2-1;yyy<=y4;yyy++) { if(yyy==y1) { return true; } } } else { for(int yyy=y2-1;yyy<=y3;yyy++) { if(yyy==y1) { return true; } } } } if((xx==x)&&(y4==y2)) { if(y4>y3) { for(int yyy=y2-1;yyy<=y4;yyy++) { if(yyy==y1) { return true; } } } else { for(int yyy=y2-1;yyy<=y3;yyy++) { if(yyy==y1) { return true; } } } } } } } } if(y2>y1) { for(int y=y1;y<=y2;y++) { if(y4>y3) { for(int yy=y3;yy<=y4;yy++) { if((yy==y)&&(x3==x1)) { if(x4>x3) { for(int xxx=x1+1;xxx<=x4;xxx++) { if(xxx==x2) { return true; } } } else { for(int xxx=x1+1;xxx<=x3;xxx++) { if(xxx==x2) { return true; } } } } if((yy==y)&&(x4==x1)) { if(x4>x3) { for(int xxx=x1+1;xxx<=x4;xxx++) { if(xxx==x2) { return true; } } } else { for(int xxx=x1+1;xxx<=x3;xxx++) { if(xxx==x2) { return true; } } } } if((yy==y)&&(x3==x2)) { if(x4>x3) { for(int xxx=x2-1;xxx<=x4;xxx++) { if(xxx==x1) { return true; } } } else { for(int xxx=x2-1;xxx<=x3;xxx++) { if(xxx==x1) { return true; } } } } if((yy==y)&&(x4==x2)) { if(x4>x3) { for(int xxx=x2-1;xxx<=x4;xxx++) { if(xxx==x1) { return true; } } } else { for(int xxx=x2-1;xxx<=x3;xxx++) { if(xxx==x1) { return true; } } } } } } else { for(int yy=y4;yy<=y3;yy++) { if((yy==y)&&(x3==x1)) { if(x4>x3) { for(int xxx=x1+1;xxx<=x4;xxx++) { if(xxx==x2) { return true; } } } else { for(int xxx=x1+1;xxx<=x3;xxx++) { if(xxx==x2) { return true; } } } } if((yy==y)&&(x4==x1)) { if(x4>x3) { for(int xxx=x1+1;xxx<=x4;xxx++) { if(xxx==x2) { return true; } } } else { for(int xxx=x1+1;xxx<=x3;xxx++) { if(xxx==x2) { return true; } } } } if((yy==y)&&(x3==x2)) { if(x4>x3) { for(int xxx=x2-1;xxx<=x4;xxx++) { if(xxx==x1) { return true; } } } else { for(int xxx=x2-1;xxx<=x3;xxx++) { if(xxx==x1) { return true; } } } } if((yy==y)&&(x4==x2)) { if(x4>x3) { for(int xxx=x2-1;xxx<=x4;xxx++) { if(xxx==x1) { return true; } } } else { for(int xxx=x2-1;xxx<=x3;xxx++) { if(xxx==x1) { return true; } } } } } } } } else { for(int y=y2;y<=y1;y++) { if(y4>y3) { for(int yy=y3;yy<=y4;yy++) { if((yy==y)&&(x3==x1)) { if(x4>x3) { for(int xxx=x1+1;xxx<=x4;xxx++) { if(xxx==x2) { return true; } } } else { for(int xxx=x1+1;xxx<=x3;xxx++) { if(xxx==x2) { return true; } } } } if((yy==y)&&(x4==x1)) { if(x4>x3) { for(int xxx=x1+1;xxx<=x4;xxx++) { if(xxx==x2) { return true; } } } else { for(int xxx=x1+1;xxx<=x3;xxx++) { if(xxx==x2) { return true; } } } } if((yy==y)&&(x3==x2)) { if(x4>x3) { for(int xxx=x2-1;xxx<=x4;xxx++) { if(xxx==x1) { return true; } } } else { for(int xxx=x2-1;xxx<=x3;xxx++) { if(xxx==x1) { return true; } } } } if((yy==y)&&(x4==x2)) { if(x4>x3) { for(int xxx=x2-1;xxx<=x4;xxx++) { if(xxx==x1) { return true; } } } else { for(int xxx=x2-1;xxx<=x3;xxx++) { if(xxx==x1) { return true; } } } } } } else { for(int yy=y4;yy<=y3;yy++) { if((yy==y)&&(x3==x1)) if((yy==y)&&(x3==x1)) { if(x4>x3) { for(int xxx=x1+1;xxx<=x4;xxx++) { if(xxx==x2) { return true; } } } else { for(int xxx=x1+1;xxx<=x3;xxx++) { if(xxx==x2) { return true; } } } } if((yy==y)&&(x4==x1)) { if(x4>x3) { for(int xxx=x1+1;xxx<=x4;xxx++) { if(xxx==x2) { return true; } } } else { for(int xxx=x1+1;xxx<=x3;xxx++) { if(xxx==x2) { return true; } } } } if((yy==y)&&(x3==x2)) { if(x4>x3) { for(int xxx=x2-1;xxx<=x4;xxx++) { if(xxx==x1) { return true; } } } else { for(int xxx=x2-1;xxx<=x3;xxx++) { if(xxx==x1) { return true; } } } } if((yy==y)&&(x4==x2)) { if(x4>x3) { for(int xxx=x2-1;xxx<=x4;xxx++) { if(xxx==x1) { return true; } } } else { for(int xxx=x2-1;xxx<=x3;xxx++) { if(xxx==x1) { return true; } } } } } } } } return false; } int main() { int t; cin>>t; int x1[t], x2[t], x3[t], x4[t], y1[t], y2[t], y3[t], y4[t]; for(int i=0;i>x1[i]>>y1[i]>>x2[i]>>y2[i]>>x3[i]>>y3[i]>>x4[i]>>y4[i]; } for(int i=0;i