fixing P matrix