Revision 1

1)added function to avoid generating {y,x} if only {x,y} appears in the
sequence
2)changed '<' to '<='