The gentry, or landed gentry in China was the elite who held privileged status through passing the Imperial exams, which made them eligible to hold office. These literati, or scholar-officials, (shenshi 紳士 or jinshen 縉紳), also called 士紳 shishen "scholar gentry" or 鄉紳 xiangshen "local gentry", held a virtual monopoly on office holding, and overlapped with an unofficial elite of the wealthy. The Tang and Song dynasties expanded the civil service exam to replace the nine-rank system which favored hereditary and largely military aristocrats. As a social class they included retired mandarins or their families and descendants. Owning land was often their way of preserving wealth.