The next time you fight off the flu, you might want to thank your ancestors for flirting with the Neanderthal down the way. According to a pair of new studies, interbreeding between several early human species may have given us a key ingredient in fighting disease.

Related Content DNA from a Huge Tooth Confirms a New Ancient Cousin

While scientists once scoffed at the idea that our ancestors may have mated with their “cousins,” over the last six years a growing body of evidence drawn from several large genetic sequencing projects says otherwise. Not only did our ancient ancestors interbreed with Neanderthals, but recent finds indicate they likely mated with a third ancient human species called the Denisovans as well.

And this wasn’t just a one-time thing. Studies indicate that our ancestors got it on with these other ancient humans often enough that us modern humans have inherited about 1 to 2 percent of our DNA from them, Sarah Kaplan reports for the Washington Post.

Now, scientists working on two independent studies have come to similar conclusions. Some of this DNA left over from liasons with Neanderthals and Denisovans play a big role in strengthening our immune systems to fight off infection and disease.

"At some point in history it might have been an advantage to have these Neanderthal genes in terms of fighting off infections or lethal pathogens from 10,000 years ago,” study co-author Michael Dannemann of the Max Planck Institute for Evolutionary Anthropology tells Helen Briggs for the BBC.

Dannemann and his colleagues analyzed genes from both modern humans and ancient Homo sapiens to see how our immune systems changed over the millennia. When they looked closely, they discovered several fragments of Neanderthal DNA in modern humans that are tied to our hardy immune systems. At the same time, researchers working on another, separate project at the Pasteur Institute in Paris came to similar conclusions while scanning the modern human genome for similarities to Neanderthal and Denisovan DNA, Ian Sample reports for The Guardian. Both studies were published this week in the American Journal of Human Genetics.

“A small group of modern humans leaving Africa would not carry much genetic variation,” Janet Kelso, co-author of the study from the Max Planck Institute, tells Sample. “You can adapt through mutations, but if you interbreed with the local population who are already there, you can get some of these adaptations for free.”

The findings indicate that modern humans inherited three genes in three waves, depending on when their ancestors interacted with Neanderthals and Denisovans—two from Neanderthals and one from the Denisovans. According to Lluis Quintana-Murci, who co-authored the study at the Pasteur Institute, these three genes are some of the most common Neanderthal or Denisovan DNA found in modern human beings, Sample reports.

While these genes may have helped our ancestors fight off disease, they are also responsible for a more unpleasant side effect: allergies. When these three genes gave our ancestors more protection from pathogens, they also made it likely that harmless things like pollen and grass could set off their burgeoning immune system. Sadly, that overactive immune response has been passed down along with the added protection, Megan Thielking writes for STAT.

“We see it as a trade-off,” Kelso tells Thielking.