A manufacturer makes two products A and B, each of which is processed in two departments, production and finishing. Each A takes 3 hours to produce and six hours to finish, whereas each B takes 5 hours to produce and 2 hours to finish. How many units of A and B can be produced and finished if exactly 24 hours are available in each department and all hours must be used?