Teach monsters how to find and use the correct stairs.

Instead of checking both stairs (up and down), check whether they come from below or from above and use the matching stairs only.

Fixes #9848