As per the Legends, a demon by the name Gayasura who was an ardent devotee of Lord Vishnu performed strict penance. Lord Vishnu appeared before him and granted his wish that whoever sees him should attain salvation. Gayasura using his spiritual powers started increasing his body size with the intention that everyone on the Earth should attain salvation. Indra, the God of Heaven worried that if everyone attains salvation then there will be an imbalance in the creation and prayed for the Lord's Vishnu, Siva and Brahma seeking a solution. Lord Vishnu, Siva and Brahma transformed themselves as a Brahmins and approached Gayasura for Yajna space. They told Gayasura that there are many evil incidents on the Earth so they want to perform Yajna on top of Gayasura body which is holy. Brahmins also told him that this Yajna will run for seven days and you should be strong enough to bear the pain if the conditions are not met then he would be killed. Gayasura accepted their request and slept by lying down on the Earth, with Head in Siro Gaya (Gaya in Bihar), Navel in Jijapur (Nabi Gaya in Orissa) and his foot in Pithapuram (Padagaya in East Godavari , Andhra Pradesh). Gayasura started counting days on rooster crowing at early hours and on the last day of the Yajna, Siva took the form of a cock and crowed in the midnight. Not knowing the trick Gayasura woke up which disturbed the Yajna. Brahmins accused Gayasura of not sticking to his promise and also told him that, if he can't bear the pain from Yajna for 7 days then how can he absorb the sins of entire humankind. Angered Brahmins were ready to kill him, Gayasura ready to offer himself as promised. Impressed Lords before him in their actual form and granted a wish that the place where he laid down would become a holy shrine with Head part to be the Lord Vishnu's holy abode, Lord Brahma at Navel part and Lord Siva at the feet. And also granted boon that performing Pindapradana will credit their ancestors and attains salvation.