Among the earliest inventions were the abacus, the public toilet, and the "shadow clock". Joseph Needham noted the "Four Great Inventions" of China as among some of the most important technological advances; these were the compass, gunpowder, papermaking, and printing, which were later known in Europe by the end of the Middle Ages. The Tang dynasty (AD 618 - 906) in particular was a time of great innovation. A good deal of exchange occurred between Western and Chinese discoveries up to the Qing dynasty.