EasyRating 1000
Sorted Grid
You may reorder the letters inside each row. Can you make every column sorted from top to bottom too? Print YES or NO.
Input
n, then n words of equal length.
Output
YES or NO.
Sample 1
Input
5 ebacd fghij olmkn trpqs xywuv
Output
YES
Sample 2
Input
3 abc lmp qrt
Output
YES
Output appears here