To solve such kind of problem you have to first draw the diagram on rough paper and things will become very simple to you as shown below.
hence you need make use of Pythagoras theorem.
let distance between M and R is X then
X² = 30² + 40²
Hence X = 50 meter
Now from the diagram you can easily make out that R is in South-East direction to M.
For faster calculation I am mentioning here Pythagorean Triplets. Remember them by heart and it will help you in calculations.