The average age of A and B is 24 years. If C replaced A, the average would be 20 and if C replaced by B, the average would be 22. What are the ages of A, B, and C respectively?