Who was the Tangs biggest rival?