#C2193. Word Square Verification

    ID: 45482 Type: Default 1000ms 256MiB

Word Square Verification

Word Square Verification

A word square is a special arrangement of words such that the words read the same both horizontally and vertically. Formally, for a list of \( n \) words, each of length \( n \), the condition is satisfied if for all valid indices \( i, j \), we have \( words[i][j] = words[j][i] \).

Your task is to determine whether a given set of words forms a valid word square.

inputFormat

The input consists of multiple test cases. Each test case is given on a separate line and contains space-separated words. The input terminates with a line containing the word "STOP" (without quotes). Each test case corresponds to a dataset that needs to be checked for the word square property.

Note: Use standard input (stdin) for input.

outputFormat

For each test case, print YES if the words form a valid word square; otherwise, print NO. Each answer should be printed on a new line. Use standard output (stdout) for output.

## sample
BALL AREA LEAD LADY
AREA LEAD BALL LARD
STOP
YES

NO

</p>