According to the Talmudic legend, King Solomon needs to cut stones for the altar of the Temple, but there is a biblical injunction against using metal instruments to cut stones used for this purpose. He, therefore, asks his wise men what to do. They advise him to seek out a worm called the shamir, which has the ability to cut through stones. They also tell him to ask the demons how to find the shamir. The demons tell King Solomon that only Ashmedai, the king of the demons, knows of the shamir's whereabouts. Therefore, King Solomon sends his trusted servant, Beniahu, to capture Ashmedai.