When hunter-gatherers living in what is now southern Denmark broke down pieces of birch bark into sticky, black tar about 5,700 years ago, they almost certainly didn’t realize that they were leaving future scientists their entire DNA.

Ancient people used the gooey birch pitch to fix arrowheads onto arrows and to repair a variety of stone tools. When it started to solidify, they rolled the pitch in their mouths and chewed on it, like some sort of primitive bubble gum. Chewing on birch pitch would have made it pliable again for using on tools.

It might have also relieved toothaches because of the antiseptic oils in the gum. It’s possible that children also used it recreationally, much like modern humans do today. When they spat the gum out, the same antiseptic properties helped preserve the DNA in their saliva.

The ancient DNA, described in a paper published Tuesday in Nature Communications, is especially valuable because few human bones from the Mesolithic and Neolithic Stone Ages have been found in Scandinavia. DNA from the chewed-up gum provides clues about the people who settled in the area, the kind of food they ate and even the type of bacteria they carried on their teeth.