Qatadah (may Allah have mercy on him) said: Jabir bin Zayd (may Allah have mercy on him) was imprisoned in the time of al-Hajjaj. Then they sent to Jabir (may Allah have mercy on him) to ask him about the inheritance of a hermaphrodite. Jabir (may Allah have mercy on him) said: You imprison me and then ask me for a fatwa as well! Then he said: Look at where he urinates from, and make him an heir accordingly. Qatadah (may Allah have mercy on him) said: I mentioned this to Sa'id bin al-Musayyib (may Allah have mercy on him), and he said: What if he urinates from both? I said: I do not know. Sa'id (may Allah have mercy on him) said: He will be made an heir according to whichever comes first.
Hadith Referenceالسنن الكبرى للبيهقي / كتاب الفرائض / 12516