In the mid 11th century, Moravia was divided into three separate territories; each had its own ruler, coming from the Přemyslids dynasty, but independent of the other two, and subordinated only to the Bohemian ruler in Prague. The seats of these rulers and thus the "capitals" of these territories were the castles and towns of Brno, Olomouc, and Znojmo. In the late 12th century, Moravia began to reunify, forming the Margraviate of Moravia. From then until the mid of the 17th century, it was not clear which town should be the capital of Moravia. Political power was divided between Brno and Olomouc, but Znojmo also played an important role. The Moravian Diet, the Moravian Land Tables, and the Moravian Land Court were all seated in both cities at once. However, Brno was the official seat of the Moravian Margraves (rulers of Moravia), and later its geographical position closer to Vienna also became important. Otherwise, until 1642 Olomouc had a larger population than Brno, and it was the seat of the only Roman Catholic diocese in Moravia.