I am getting WA. Algorithm looks correct to me. Am I missing any corner cases?
main()
{
ll tst;
cin>>tst;
while(--tst)
{
ll x1,y1,x2,y2,X1,Y1,X2,Y2,ans=0,overlap=0,startx,endx,starty,endy,ans1,ans2;
cin>>x1>>y1>>x2>>y2;
cin>>X1>>Y1>>X2>>Y2;
ans1= (x2-x1)*(y2-y1) ;
ans2=(X2-X1)*(Y2-Y1);
if(ans1>=0) ans+= ans1; else ans-=ans1;
if(ans2>=0) ans+= ans2; else ans-=ans2;
startx = (X1>x1)? X1:x1;
endx = (x2<X2)? x2:X2;
starty = (Y1>y1)? Y1:y1;
endy = (y2<Y2)? y2:Y2;
if(startx<endx && endy>starty)
ans-= (endx-startx)*(endy-starty);
cout<<ans<<endl;
}
}