How many rectangles can be formed out of a grid consisting of intersecting horizontal and vertical lines?