Five friends P. O, X, Y and Z purchased some notebooks. The relevant information is given below:
1. Z purchased 8 notebooks more than X did.
2. P and Q together purchased 21 notebooks.
3. O purchased 5 notebooks less than P did.
4. X and Y together purchased 28 notebooks.
5. P purchased 5 notebooks more than X did.
If each notebook is priced 40, then what is the total cost of all the notebooks?