The "five altars" refer to the Temple of Heaven, the Temple of Earth, the Temple of the Sun, the Temple of the Moon and the Agricultural God Altar, which were built in the Ming Dynasty and continued to be used in the Qing Dynasty. These were built by the emperors of the Ming and Qing dynasties to worship the gods of heaven, earth, sun, moon, mountains and stars. The eight temples refer to the the Imperial Ancestral Temple, the Hall of Fengxian, the Hall of Chuanxin, the Hall of Longevity, the Lama Temple, the Imperial Sacrificial Temple, the Temple of Literature and the Temple of the Emperors. In feudal times, these temples were the places where the emperors worshiped the ancestors, gods and Buddhas and sages of the past generations. In addition to the Hall of the Fengxian and the Hall of Chuanxin are inside the Forbidden City, the rest are in Beijing city.