suba (xz:yz:xm:ym:x:y:1:_) = if x > xz
	then [x, yz, xm, ym]
	else [xz, yz, xm, ym]

suba (xz:yz:xm:ym:x:y:2:_) = if x < xm
	then [xz, yz, x, ym]
	else [xz, yz, xm, ym]

suba (xz:yz:xm:ym:x:y:3:_) = if y > yz
	then [xz, y, xm, ym]
	else [xz, yz, xm, ym]

suba (xz:yz:xm:ym:x:y:4:_) = if y < ym
	then [xz, yz, xm, y]
	else [xz, yz, xm, ym]

isZero n = if n < 0
	then 0
	else n

solve' (xc:xs) = if null xs
	then isZero (xc !! 2 - xc !! 0) * (xc !! 3 - xc !! 1)
	else solve' $ [suba $ xc ++ head xs] ++ tail xs

solve (x1:xs) =	solve' $ [[0, 0] ++ init x1] ++ xs

main = print . solve . map (map read) . map words . lines =<< getContents
