Valmiki Ramayana Bala Kanda Sarga 25 Shloka 17
Original Shlokaनृशंसमनृशंसं वा प्रजारक्षणकारणात्। पातकं वा सदोषं वा कर्तव्यं रक्षता सता।।1.25.17।।
1 source checked for this shloka
रक्षता while protecting, सता by a virtuous man, प्रजारक्षणकारणात् for the welfare of the subjects, नृशंसं वा either cruel, अनृशंसं वा or not cruel ,पातकं वा or a sin, सदोषं वा or involving a mistake, कर्तव्यम् should be done.
Whether cruel or kind, sinful or wrong whatever contributes to the protection of the subjects, should be done by the righteous (king).