P7035 [NWRRC 2016] Easy Reading

Description

Eugene is reading a boring book. To make this process interesting he is drawing a picture at the same time. He has a piece of graph paper that is divided into square cells. All the cells are empty at the beginning. Eugene starts by painting over one cell. Then he opens the book at a random page and starts reading.  Whenever he sees the letter `u` in the text, he moves his pen one cell up and then paints over the cell under his pen. Whenever he sees the letter `d`, he does the same but moves his pen one cell down instead of up. For letters `l` and `r` he moves to the left and to the right, respectively. If he wants to paint a cell that was already painted, he paints it again. You have found a piece of paper and the text of the book. Now you want to understand if the picture o_n the paper could be drawn by Eugene at some point of his book reading. Remember that Eugene could use some substring of the text.

Input Format

N/A

Output Format

N/A

Explanation/Hint

Time limit: 2 s, Memory limit: 256 MB.