Sponsored
Use these hints if you're stuck. Try solving on your own first.
As the constraints are not large, you can brute force and enumerate all the possibilities.
Solve with full IDE support and test cases