- Keep a base of controlling vectors for each prime number.
- Keep $n_vec - the vector starting with n[sq] that has to be composed out of the base.
- As we encounter the next integer $i -
- Get its squaring factors
- Check if it's not square or prime (which are useless for us)
- Stair-shape it, by multiplying it with the controlling vectors of its factors
- Possibly assign it as the controlling vector of the minimal (ID-wise) prime in its stair shape version, and canonize the rest of the base accordingly.
- Try to canonize $n_vec.
- Once $n_vec becomes 0, we stop and return.