Make qed accept matrix of chains