Pensieve header: Implementing KH, day 1.

K=Xp[4,2,5,1]Xp[2,6,3,5]Xp[6,4,1,3]

(Subscript[S, a__])[K_] := Table[
{{a}[[i]],K[[i]]},{i,1,Length[K]}
] /. {
{0,Xp[i_,j_,k_,l_] :>...},
{1, Xp} :>   ..
{0,Xm} :> ...