The spouse and the children accompanying the person posted to the territory of the other Contracting Party under Article 14 or 17 of the Regulation shall be subject to the legislation of the same Contracting Party as the posted person and treated as if they were resident in the territory of that Contracting Party unless they are themselves gainfully occupied in the territory of the Contracting Party to which the person is posted, or they are insured on the basis of receiving a pension or a cash benefit under the legislation of this Contracting Party.