Ranked solutions of AXC=B and AX=B