Create n sets where S[i]={a[i],a[a[i]],a[a[a[i]]]}