Right now I'm thinking the only possible solutions are when a=c, b=d or when a=d, b=c. So this is what I have, but it doesn't use a heap. I'm still not entirely sure what I would want to store in the heap.
for (i : 1,...,n)
...for(j : 1,...,n)
...insert into array (i, j, i, j)
...if (i != j)...