Jeyeon wants to join Mensa, and while working through Mensa math quizzes he found out something odd. Mensa members do not use ordinary safes. Their safe has buttons arranged in a grid, and it works like this.
- Pick one button, press it, and read the label written on it.
- A label is one number followed by one letter. The letter is U (up), D (down), L (left) or R (right), and you move that many cells in that direction.
- Press the button you land on, then repeat steps 1 and 2.
- If you press a button that was already pressed, the safe stays shut. The moment every button has been pressed once, the safe opens.
Jeyeon liked the mechanism enough to build his own Mensa safe, so he wrote numbers and letters into an N×N grid however he liked. Once he was done he no longer knew which button to start from. Find the button that opens the safe.