The Shang Dynasty emerged in China between 1532-1027 BC. They were the first documented Chinese dynasty and established their main capital at Anyang. Cities were protected by earthen walls and consisted of mostly wooden structures and homes. Society was sharply divided into social classes ruled by a warrior king. The king's authority was believed to come from heaven through the Mandate of Heaven, and dynasties would rise and fall in a dynastic cycle. Writing first developed through oracle bones where priests would interpret cracks made by heat on bones or shells that kings used to consult with gods.