#K69002. Command Validator

    ID: 32989 Type: Default 1000ms 256MiB

Command Validator

Command Validator

In this problem, you are given commands to validate. Each command consists of space-separated parts. A command must start with an action among MOVE, REMOVE or COPY, followed by a subject, and optionally an object. Both the subject and the object (if present) must be composed entirely of uppercase English letters (i.e., A–Z).

The command is valid if and only if all of the following conditions hold:

  • The command has either 2 or 3 tokens.
  • The first token is one of \(\{MOVE,\ REMOVE,\ COPY\}\).
  • The second token (subject) matches the regular expression \( ^[A-Z]+$ \).
  • If a third token (object) is provided, it also matches \( ^[A-Z]+$ \).

Your task is to determine for each command whether it is VALID or INVALID.

inputFormat

The input is read from standard input and consists of multiple lines. The first line contains an integer n — the number of commands. The following n lines each contain a command to be validated.

outputFormat

For each command, output a single line containing either VALID or INVALID according to the validation rules.

## sample
3
MOVE BOX
REMOVE BOX CHAIR
COPY BOOK SHELF
VALID

VALID VALID

</p>