200 - Rare Order

Solved using Topological sort