The generalization of the the Yang-Baxter relation is proposed. In this generalization the spectral parameters of the particles change after the scattering. The corresponding algebraic structures are discussed. The corresponding action of the symmetric group is studied. The most interesting examples of such action are connected with factorization of matrix polynomials and matrix $theta$-functions. The generalization of the star-triangle relation is also proposed.