Fix all of the grammatical issues in the given sentence
By the time we arrived the shrine, We took the wrong train, missed our stop, and were out of breath from climbing the steep and narrow stone steps.
By the time we arrived at the shrine, we had took taken the wrong train, missed our stop, and were out of breath from climbing the steep and narrow stone steps.