Answer:
Due to the complexity of this, I have added the solution to each part as separate attachments.
Personally, I feel that this was quite complex and may have been beneficial to ask as separate questions.
Step-by-step explanation:
If you need any specific part explaining, please ask in response to this.