...
{d(0,2n), d(0,2n+1), d(0,2n+2), ..., d(0,3n-1), d(1,2n), d(1,2n+1), d(1,2n+2), ..., d(1,3n-1)}
...
The result of 2nd call each iteration will have some duplications duplication with the result of 1st callprevious iteration, use need do duplication check and remove them.
...