There are 30 students in a class. The average age of the first 10 students is 12.5 years. The average age of the remaining 20 students is 13.1 years. The average age (in years) of the students of the whole class is:
A12.5 years
B12.7 years
C12.8 years
D12.9 years