logo AlgoBeat OnlineJudge
登录 注册

#206193. [NWRRC 2016] Easy Reading

内存限制:256 MiB 时间限制:2000 ms 标准输入输出
题目类型:VJudge(洛谷) 评测方式:VJudge
上传者: 匿名

题目描述

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.

输入格式

The first line of the input contains an integer -- the length of the text . The contains a string of length -- the text. It contains only lowercase English letters, spaces, commas and periods. The text neither begins nor ends with a space.

The third line contains two positive integers and -- the picture dimensions .

Each of the following lines contains a string of length . Painted cells are denoted by X, while empty cells -- by . . It is guaranteed that there are at least two painted cells in the picture.

The first of these lines corresponds to the top of the picture and the last one corresponds to the bottom of it.

输出格式

If the picture could be painted by Eugene, output YES on the first line. On the second line print two integers b and such that if Eugene read all letters from to , inclusive, he would draw exactly picture as described in the input . If there are several solutions, output any of them.

If the picture couldn't be drawn by Eugene, output NO.

样例

样例输入 1

43
you should read statement really carefully.
3 6
...XX.
..XXX.
...XXX

样例输出 1

YES
3 42

样例输入 2

43
you should read statement really carefully.
3 2
XX
XX
XX

样例输出 2

NO

数据范围与提示

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