generates the next permutation
next(n,&done);