In the 9th and 10th centuries, kings were very weak and lacked armies or means to protect their kingdoms from Vikings, Saracens, and Magyars. Since they did not have the king's protection, peasants sought the protection of the nobles and their castles. Thus, feudalism was born, in which the nobles accepted the king's power through a vassalage pact, but they themselves acted as 'kings' in their fiefs (territories). The society was divided into three groups called estates: the nobility, the clergy