#abc302c. [abc302_c]Almost Equal
[abc302_c]Almost Equal
Problem Statement
You are given strings , each of length , consisting of lowercase English letter. Here, are pairwise distinct.
Determine if one can rearrange these strings to obtain a new sequence of strings such that:
- for all integers such that , one can alter exactly one character of to another lowercase English letter to make it equal to .
Constraints
- is a string of length consisting of lowercase English letters.
- are pairwise distinct.
Input
The input is given from Standard Input in the following format:
Output
Print Yes
if one can obtain a conforming sequence; print No
otherwise.
Sample Input 1
4 4
bbed
abcd
abed
fbed
Sample Output 1
Yes
One can rearrange them in this order: abcd
, abed
, bbed
, fbed
. This sequence satisfies the condition.
Sample Input 2
2 5
abcde
abced
Sample Output 2
No
No matter how the strings are rearranged, the condition is never satisfied.
Sample Input 3
8 4
fast
face
cast
race
fact
rice
nice
case
Sample Output 3
Yes