Tetris Game Validator
Recall the Tetris problem statement:
*In the game of Tetris, connected figures (connected if they can move in four directions) fall into a well with N rows and 20 columns. Each figure is represented by a unique letter from the English alphabet, ranging from "A" to "Z". While falling, the figures cannot be moved or rotated. Your task is to determine the sequence in which the blocks fell, based on the description of the well.*
**Input Format**
The first line of the input file contains an integer N (0 ≤ N ≤ 50) — the number of rows in the well. Each of the following rows consists of 20 characters, each being either a letter from "A" to "Z" or the character "." (ASCII 46), indicating an empty cell.
You need to write a test validator for this problem.
**Input Format**
The input file contains several tests. Each test is formatted as follows:
The number **N** (**1** ≤ **N** ≤ **50**) followed by **N** rows, each containing 20 characters.
Characters can have ASCII codes ranging from **32** to **127**.
The total sum of **N** across all tests will not exceed **500000**.
**Output Format**
For each test, output **YES** or **NO** — indicating whether the test is valid.
A test is considered valid if all the following conditions are satisfied:
- Only characters "A..Z" and "." are used. - A figure (i.e., the set of all cells with a specific letter) forms a connected area. - No figure is "hanging in the air". - The figures could indeed have fallen in such an order.