The *fundamental principle of counting* states that given two independent events (what happens in one does not affect what happens in the other), if there are #m# ways for one to occur and #n# ways for the other to occur, then there are #m*n# ways for them to occur together.

We will also make use of the fact that given a set of #n# distinct items, there are #n!# ways to arrange them in a row. To see this, note that there are #n# ways to choose the first item, and then #n-1# ways to choose the second for each choice of the first, and then #n-2# ways to choose the third for each choice of the second, and so on. Thus, the total is #n(n-1)(n-2)...(2)(1)=n!#

There is some ambiguity as to whether the given conditions are to be treated as separate problems or taken as a whole, so we will consider all cases:

**Total arrangements with no conditions:**

This is simply arranging #20# distinct items in a row. By the above, there are #20!# ways to do so.

**Total arrangements with each set remaining together:**

If each set remains together, then we may treat each set as a single item. Then, as there are #3# sets and #4# single volumes, there are #7# items to put in a row, giving #7!# options. However, within each set, we can rearrange the items.

There are #3!# ways to arrange the 3-volume set, #5!# ways to arrange the 5-volume set, and #8!# ways to arrange the 8-volume set. As these arrangements are independent of the order in which the sets appear, the fundamental principle of counting allows us to multiply them to find the total number of arrangements. Thus, the total number is #7!*3!*5!*8!#

**Total arrangements with earlier volumes preceding later volumes in a set, not necessarily together:**

For this one, we will use a powerful tool for counting: the number of ways to choose #k# items from a set of #n#, denoted #((n),(k))# and pronounced *n choose k*, is given by #((n),(k)) = (n!)/(k!(n-k)!)# (see this site for the derivation of this formula and more).

Proceeding, we can note that for any multi-volume set, the order of those volumes is fixed, meaning the only thing that changes is their placement among the #20# possible spots. There are #((20),(8))# ways to choose the spots for the 8-volume set, #((12),(5))# ways to choose spots for the 5-volue set from the remaining #12# spots, and #((7),(3))# ways to choose for the 3-volume set from the remaining #7# spots.

After that, all that remains is to order the #4# single volumes, which, by the initial discussion, is #4!#. Thus, the total number of ways is #((20),(8)) * ((12),(5)) * ((7),(3)) * 4!#

**Total arrangements with sets remaining together and in ascending order:**

As in the second problem, because the sets must remain together, we can treat them as single items for the purpose of choosing what order they appear. Together with the single volumes, that again gives us #7# items to order. However, this time the multi-volume sets have a fixed internal order, meaning we do not need to consider any further arrangements beyond which sets come first. Thus there the total number is just arranging #7# items, which is #7!#.