Compact solution

Compact solution