I wondered this myself several years ago and this is what I came up with.
Matthew carries the line of Jesus from Abraham to Mary. You can see where the line changes at David.
Mary is from Solomon, son of David and Joseph is from Nathan, son of David
Matthew 1: 1:
This is a record of the family line of Jesus Christ. He is the son of David. He is also the son of Abraham.
2 Abraham was the father of Isaac.
Isaac was the father of Jacob.
Jacob was the father of Judah and his brothers.
3 Judah was the father of Perez and Zerah. Tamar was their mother.
Perez was the father of Hezron.
Hezron was the father of Ram.
4 Ram was the father of Amminadab.
Amminadab was the father of Nahshon.
Nahshon was the father of Salmon.
5 Salmon was the father of Boaz. Rahab was Boaz's mother.
Boaz was the father of Obed. Ruth was Obed's mother.
Obed was the father of Jesse.
6 And Jesse was the father of King David.
David was the father of Solomon. Solomon's mother had been Uriah's wife.
7 Solomon was the father of Rehoboam.
Rehoboam was the father of Abijah.
Abijah was the father of Asa.
8 Asa was the father of Jehoshaphat.
Jehoshaphat was the father of Jehoram.
Jehoram was the father of Uzziah.
9 Uzziah was the father of Jotham.
Jotham was the father of Ahaz.
Ahaz was the father of Hezekiah.
10 Hezekiah was the father of Manasseh.
Manasseh was the father of Amon.
Amon was the father of Josiah.
11 And Josiah was the father of Jeconiah and his brothers. At that time, the Jewish people were forced to go away to Babylon.
12 After this, the family line continued.
Jeconiah was the father of Shealtiel.
Shealtiel was the father of Zerubbabel.
13 Zerubbabel was the father of Abiud.
Abiud was the father of Eliakim.
Eliakim was the father of Azor.
14 Azor was the father of Zadok.
Zadok was the father of Akim.
Akim was the father of Eliud.
15 Eliud was the father of Eleazar.
Eleazar was the father of Matthan.
Matthan was the father of Jacob.
16 Jacob was the father of Joseph. Joseph was the husband of Mary. And Mary gave birth to Jesus, who is called Christ.
Luke carries the line of Jesus back to Adam through the line of Joseph (Mary's husband)
Luke 3: 23 Jesus was about 30 years old when he began his special work for God and others. It was thought that he was the son of Joseph.
Joseph was the son of Heli. 24 Heli was the son of Matthat.
Matthat was the son of Levi.
Levi was the son of Melki.
Melki was the son of Jannai.
Jannai was the son of Joseph. 25 Joseph was the son of Mattathias.
Mattathias was the son of Amos.
Amos was the son of Nahum.
Nahum was the son of Esli.
Esli was the son of Naggai. 26 Naggai was the son of Maath.
Maath was the son of Mattathias.
Mattathias was the son of Semein.
Semein was the son of Josech.
Josech was the son of Joda. 27 Joda was the son of Joanan.
Joanan was the son of Rhesa.
Rhesa was the son of Zerubbabel.
Zerubbabel was the son of Shealtiel.
Shealtiel was the son of Neri. 28 Neri was the son of Melki.
Melki was the son of Addi.
Addi was the son of Cosam.
Cosam was the son of Elmadam.
Elmadam was the son of Er. 29 Er was the son of Joshua.
Joshua was the son of Eliezer.
Eliezer was the son of Jorim.
Jorim was the son of Matthat.
Matthat was the son of Levi. 30 Levi was the son of Simeon.
Simeon was the son of Judah.
Judah was the son of Joseph.
Joseph was the son of Jonam.
Jonam was the son of Eliakim. 31 Eliakim was the son of Melea.
Melea was the son of Menna.
Menna was the son of Mattatha.
Mattatha was the son of Nathan.
Nathan was the son of David. 32 David was the son of Jesse.
Jesse was the son of Obed.
Obed was the son of Boaz.
Boaz was the son of Salmon.
Salmon was the son of Nahshon. 33 Nahshon was the son of Amminadab.
Amminadab was the son of Ram.
Ram was the son of Hezron.
Hezron was the son of Perez.
Perez was the son of Judah. 34 Judah was the son of Jacob.
Jacob was the son of Isaac.
Isaac was the son of Abraham.
Abraham was the son of Terah.
Terah was the son of Nahor. 35 Nahor was the son of Serug.
Serug was the son of Reu.
Reu was the son of Peleg.
Peleg was the son of Eber.
Eber was the son of Shelah. 36 Shelah was the son of Cainan.
Cainan was the son of Arphaxad.
Arphaxad was the son of Shem.
Shem was the son of Noah.
Noah was the son of Lamech.
37 Lamech was the son of Methuselah.
Methuselah was the son of Enoch.
Enoch was the son of Jared.
Jared was the son of Mahalalel.
Mahalalel was the son of Kenan.
38 Kenan was the son of Enosh.
Enosh was the son of Seth.
Seth was the son of Adam.
Adam was the son of God.