Since the period of the Northern and Southern Courts, discrimination between "nainai" and "tozama" was created according to the closeness to the then current emperor.
南北朝期以降堂上家のなかに、時の天皇との親疎により内々・外様の区別が出来た。