Context: Tibet was once a strong power contemporaneous with Tang China (618–907). Until the Tibetan Empire's collapse in the 9th century, it was the Tang's major rival in dominating Inner Asia. The Yarlung rulers of Tibet also signed various peace treaties with the Tang, culminating in a treaty in 821 that fixed the borders between Tibet and China.

Question: In what century did the Tibetan Empire fall?
Answer: the 9th century

Question: Who signed multiple peace treaties with the Tang? 
Answer: The Yarlung rulers of Tibet

Question: What did one of the treaties between the Tang and Tibet help fix?
Answer: the borders between Tibet and China

Question: Who was the Tangs biggest rival?
Answer: Tibet

Question: What year did Tang and Tibet sign a treaty to fix the borders?
Answer: 821