No. of quadrilaterals

Can anyone give the generalised formula of no. of squares and rectangles formed when m*n parallel lines intersect. Pls explain as well.