Ancient Egypt prospered due to its stable government structure and interaction with other cultures. The Egyptian empire was first formed along the fertile Nile River valley. A unified kingdom was established around 3100 BC under King Menes, beginning the Old Kingdom period of pyramid building. Subsequent kingdoms including the Middle Kingdom and New Kingdom expanded Egypt's territories and established trade networks, while maintaining political and religious rule centered on the pharaoh.