Mahabharatha, Shanthi Parva, Section 65 (Chapter 159 in BORI CE):
A person who violates his preceptor’s bed is evil in his soul and wicked in his intelligence. He must embrace a blazing Surmi and death will purify him. Or he may himself sever his penis and testicles and holding them in his hands, walk straight in the southwest direction, until he dies and falls down. If he gives up his life for the sake of a Brahmana, he will be purified.
Also from Apasthambha Dharma Soothra, Prasna 1, Patala 9, Khanda 25:
- He who has had connection with a Guru’s wife shall cut off his organ together with the testicles, take them into his joined hands and walk towards the south without stopping, until he falls down dead
Solution, from Manu Smrithi 11.251:
हविष्पान्तीयमभ्यस्य न तमं ह इतीति च ।
जपित्वा पौरुषं सूक्तं मुच्यते गुरुतल्पगः ॥ २५१ ॥haviṣpāntīyamabhyasya na tamaṃ ha itīti ca | japitvā pauruṣaṃ sūktaṃ mucyate gurutalpagaḥ || 251 ||
The Violator of the Preceptor’s Bed becomes absolved by repeating the ‘Haviṣpāntīya Hymn,’ (Ṛgveda, 10.88.1), the verse beginning with ‘na tamam ha’ (Ṛgveda, 10.126) and that beginning with ‘iti’ (Ṛgveda, 10.119),—and by reciting the ‘Puruṣasūkta’ (Ṛgveda, 10.90.1)—(251)