Sorry but there needs more than 7 races I think. Even with your logic it cannot confirm that B3,b4,b5 and a4,a5 are eliminated. So a1 to a5, b1 to b5, c1 (total 11) must race again. But we know a1 is the fastest. Then race other 10. You get top 2 in both group = 4. Race those 4 and a1 to get top 3.
So i feel 9 is least no . Of races required.
@alpeshupadhye4747