Luckily Unfortunately, Jonathan could not find anyone who could solve his puzzle. Instead, he decides that he will instead propose to the first person he sees by giving them a box of chocolates. While running across a grassy field to deliver this box of chocolates, he accidentally drops it somewhere in the field.
The field can be represented as a 2D grid with dimensions by where .
represents an open area, J
represents Jonathan's starting position and C
represents the position of the dropped chocolates. Jonathan plans to find the chocolates by moving up one space then moving right one space and repeating these steps (up one, right one) until he exits the field. Will Jonathan be able to find his chocolates?
Input Specification
The first line of input contains two integers and ().
The next lines of input will contain characters, consisting only of one J
, one C
and the rest .
.
Output Specification
Output YES
if Jonathan can find his chocolate or NO
otherwise.
Sample Input 1
2 2
.C
J.
Sample Output 1
YES
Comments