The islands of Japan were inhabited as early as the Upper Paleolithic period, though the first mentions of the archipelago appear in Chinese chronicles from the 1st century AD. Between the 4th and 9th centuries, the kingdoms of Japan became unified under an emperor and imperial court based in Heian-kyō. Starting in the 12th century, however, political power was held by a series of military dictators (shōgun), feudal lords (daimyō), and a class of warrior nobility (samurai). After a century-long period of civil war, the country was reunified in 1603 under the Tokugawa shogunate, which enacted a foreign policy of isolation. In 1854, a United States fleet forced Japan to open trade to the West, leading to the end of the shogunate and the restoration of imperial power in 1868. In the Meiji era, the Empire of Japan adopted a Western-style constitution and pursued industrialization and modernization. Japan invaded China in 1937; in 1941, it entered World War II as an Axis power. After suffering defeat in the Pacific War and two atomic bombings, Japan surrendered in 1945 and came under an Allied occupation, during which it adopted a post-war constitution. It has since maintained a unitary parliamentary constitutional monarchy with an elected legislature known as the National Diet.