In a school, Class A has 20 students, and their average score on a history exam was 80. Class B has 30 students. When the scores of both classes are combined, the overall average score for all 50 students is 86. What was the average score for Class B?