modern Slovakia. After their defeat on the river Lech, the Hungarians abandoned their nomadic ways and settled in the centre of the Carpathian valley, slowly adopting Christianity and began to build a new state — the Hungarian kingdom. Slovaks seemed to play an important role during the development of the realm. as evident by large number of loanwords into Hungarian language, concerning primarily economical, agricultural or metallurgy fields. In the years 1001–1002 and 1018–1029, Slovakia was part of the Kingdom of Poland, having been conquered by Boleslaus I the Brave. After the territory of Slovakia was returned to Hungary, a semi-autonomous polity continued to exist (or was created in 1048 by king Andrew I) called Duchy of Nitra. Comprising roughly the territory of Principality of Nitra and Bihar principality, they formed what was called a tercia pars regni, third of a kingdom. It used to be ruled by would-be successors to the throne from the house of Arpád. Interestingly, in the Hungarian-Polish chronicle from 13th century, the ruler of said duchy, duke Emeric (son of Stephen I of Hungary), is called "Henricus dux Sclavonie", in essence - duke of Slovakia. This polity existed up until 1108/1110, after which it was not restored. After this, until the year 1918, when the Austro-Hungarian empire collapsed, the territory of Slovakia was an integral part of the Hungarian state. The ethnic composition of Slovakia became more diverse with the arrival of the Carpathian Germans in the 13th century and the Jews in the 14th century. A significant decline in the population resulted from the invasion of the Mongols in 1241 and the subsequent famine. However, in medieval times the area of Slovakia was characterised by German and Jewish immigration, burgeoning towns, construction of numerous stone castles, and the cultivation of the arts. The arrival of German element sometimes proved a problem for the autochthonous Slovaks (and even Hungarians in the broader Hungary), since they often quickly gained most power in medieval towns, only to later refuse to share it. Breaking of old customs by Germans often resulted in national quarrels. One of which had to be sorted out by the king Louis I. with the proclamation Privilegium pro Slavis (Privilege for Slovaks) in the year 1381. According to this privilege, Slovaks and Germans were to occupy each half of the seats in the city council of Žilina and the mayor should be elected each