A combinatorial theorem with an application to latin rectangles