시간 제한 메모리 제한 제출 정답 맞은 사람 정답 비율
1 초 512 MB 10 7 7 70.000%

문제

Your ACM team has gathered in a picturesque city of Petrozavodsk for a team-building camp. You’ve heard that just outside of the city there is a Jigglypuff field that might help you make stronger bonds with your teammates, so you’re definitely giving it a try.

The field is a rectangle partitioned into n · m squares grouped into n rows and m columns. Each square contains a single Jigglypuff, which produces a note when a team member steps on its cell. Each note can be described by a single lowercase English character.

You and your two teammates will stand in the top-left corner of the field. Each of you will then go to the bottom-right corner, moving only right and down. Each of you has to pick a different route through the field.

Jigglypuff have psychic abilities. Therefore, if each of you hears exactly the same sequence of notes when passing through the field, your brains will perfectly synchronize and the team-building exercise will be complete. Is it possible to do so?

입력

The first line contains two integers n, m (2 ≤ n, m ≤ 3000) — the height and the width of the field. The following n lines describe the field. Each of these lines contains a single string of length m consisting of lowercase English characters. The first character in the first line is the top-left corner of the field.

출력

Output YES if it’s possible to hear the same sequence of notes on at least three different routes through the grid, or NO otherwise. Each character can be printed in any case (either uppercase or lowercase).

예제 입력 1

5 8
petrozav
eiiiziio
tiiiavid
riiiiois
ozavodsk

예제 출력 1

YES

예제 입력 2

5 5
abcde
fghij
klmno
pqrst
uvwxy

예제 출력 2

NO

힌트

The following picture shows the first example test and three paths generating the same sequence of notes — petrozavodsk: