There were two ancient dynasties in India.
Other dynasties have sprung from the two.
These two dynasties are,
Surya Vamsa, the Solar Dynasty and
Chandra Vamsa, the Lunar dynasty.
Lord Rama belonged to Ikshvaku Dynasty which is the same as Surya Vamsa, Solar Dynasty.
Pandavas and Kauravas belonged to Chandra Vamsa,Lunar Dynasty.
When one tries to find out the origin of Man Genealogy, and the first pair , one gets stuck, either with Incest or the origin of one of the pair remaining with no visible parentage.
I seek the indulgence of the readers for my vagueness in the foregoing sentence.
This is to avoid that useless controversy.
Those who can read between the lines would understand.
Now to the point at hand.
If there were two dynasties, then who was the first one; how did the second dynasty come into play;how these two are related?
Indian texts are clear on Cosmology and Genealogy, besides pther things.
There are Eighteen Puranas and many Upa Puranas.
Please read my post on list of Indian Texts.
There may be minor variations in details among the Puranas, but all agree on essential major facts.
Thus Genealogy and Cosmology descriptions, explanations do not have discrepancies among the Puranas.
Thus under Genealogy, Puranas describe the dynasties and list the Kings.
It may not be of place to mention that Cosmology and Genealogy are two of the characteristics laid down for a text to be qualified as Purana.
Please read my article on Characteristics of Purana.
The Firs human was Manu, He is called Vaivaswatha Manu for the present Time scale, Kali Yuga, which has a span of 4,32,000 years.
He had one daughter and nine sons.
Manu begot ten other children named Vena, Dhrishnu, Narishyan,Nabhaga, Ikshvaku, Karusha, Sharyati, the eighth, a daughter named Ila, Prishadhruthe ninth, and Nabhagarishta, the tenth. ( https://en.m.wikipedia.org/wiki/Shraddhadeva_Manu#Descendants )
His son Ikshvaku was from the south of the Vindhya mountains, Dravida Desa.
His kingdom was centered around Madagascar.
When a Tsunami struck , Manu mediatated in a plateau near Madagascar.
He left south with his sons for Ayodhya, where he founded the Solar Dynasty, called as Surya Vamsa.
Manu had left his only daughter Ila in the South.
She remained in the South,Dravida Desa.
Her descendants ruled from the south.
This dynasty is the Chandra Vamsa, Lunar Dynasty.
The descendants of Ila and Ikshvaku are first cousins.
In Hindu way of explaining relationships, children of aunt and uncle.
Though both Ila and Ikshvaku belong to the Genealogy of Manu, the Dynasty is called Ikshvaku, Manu’s son.
I shall write as to why.
While the dynasty of Ikashvaku is called Solar, that of Ila is Lunar, Chandra Vamsa.
Chandra Vamsa is named after Chandra, Moon.
Ila was both a man and woman.
‘According to the Ramayana, when Ila approached Shiva for help, Shiva laughed with scorn but the compassionate Parvati reduced the curse and allowed Ila to switch genders every month. However, as a male he would not remember his life as a female and vice versa. While Ilā roamed the forest in her new form with her female attendants, Budha, the god of the planet Mercury and the son of the moon-god Chandra, noticed her. Although he had been practising asceticism, Ilā’s beauty caused him to fall in love with her at first sight. Budha turned Ilā’s attendants into Kimpurushas (hermaphrodite, lit. “is it a man?”) and ordered them to run away, promising that they would find mates as Ilā had.
Ilā married Budha and spent an entire month with him and consummated the marriage. However, Ilā woke one morning as Sudyumna and remembered nothing about the past month. Budha told Ila that his retinue had been killed in a rain of stones and convinced Ila to stay with him for a year. During each month she spent as a woman, Ilā had good time with Budha. During each month as a man, Ila turned to pious ways and performed austerities under the guidance of Budha. In the ninth month, Ilā gave birth to Pururavas, who grew to become the first king of the Lunar dynasty. Then, as per the advice of Budha and Ila’s father Kardama, Ila pleased Shiva with a horse sacrifice and Shiva restored Ila’s masculinity permanently.
Another legend from the Vishnu Purana credits Vishnu of restoring Ilā’s manhood as Sudyumma. The Bhagavata Purana et al. texts tell that after Pururavas’s birth, the nine brothers of Ila – by horse sacrifice – or the sage Vasistha – the family priest of Ila – pleased Shiva to compel him to give the boon of alternate month manhood to Ila, turning him into a Kimpurusha.The Linga Purana and the Mahabharata record the birth of Pururavas, but do not narrate the end of Ila’s alternating gender condition. In fact, the Mahabharata describes Ilā to be the mother as well as the father of Pururavas.According to another account found in the Vayu Purana and the Brahmanda Purana, Ilā was born female, married Budha, then was transformed into a male called Sudyumna. Sudyumna was then cursed by Parvati and transformed once again into a female, but became a man once again through Shiva’s boon.
In almost all versions of the tale, Ila wants to live as a man, but in the Skanda Purana, Ila desires to be a woman. The king Ela (Ila) entered Parvati’s grove at Sahya mountain and became the woman Ilā. Ilā wished to remain a woman and serve Parvati (Gauri) and Ganga, the goddess of the Ganges river. However, the goddesses dissuaded him. Ilā bathed in a sacred pool and returned as Ela, bearded and deep-voiced.’
The Bhagavata Purana, the Devi-Bhagavata Purana and the Linga Purana declare that Ila ascended to heaven with both male and female anatomy. Ila is considered the chief progenitor of the Lunar Dynasty through Pururavas and of the Solar Dynasty through his brother Iksavaku and sons Utkala, Gaya, and Vinatashva. The marriage of Ilā, a descendant of the Sun, and Budha, the son of the Moon, is the first union of the solar and lunar races recorded in the scriptures.
Reference and citation.