Write an algorithm that will output the path while collecting capital letters inside a matrix representing the grid of elements

I have this exercise task where you are required to gather data on a specific path, such as a walking route. You need to follow a
path of characters and collect letters:

● Start at the character >

● Follow the path

● Collect letters

● Stop when you reach the character s

Input: A matrix representing the grid, it can be constant
Output:

  • Path
  • Letters

This is the example

enter image description here

This is the Output:

  • Path @—A—+|C|+—+|+-B-s
  • Letters ACB

This is for the assignment

enter image description here

These are the rules

  • The only valid characters are all uppercase letters (A-Z)
  • Turns can be letters or +

https://codeshare.io/NKoe6V

The output is >—A-@-+s, after the first row it goes straight to the end to “s”