The average number of pupils in both Class A and Ckass B is 36. Class A has 4 more pupils than Class B. How many pupils are there in each class?