#C5779. Alphabetical Name Checker

    ID: 49465 Type: Default 1000ms 256MiB

Alphabetical Name Checker

Alphabetical Name Checker

You are given a list of names. For each name, you need to determine whether the characters in the name are in alphabetical order (i.e. sorted in non-decreasing lexicographical order). The task is to print "VALID" if the characters of the name are in order, and "INVALID" otherwise.

More formally, a name s is considered valid if it satisfies the following condition: \[ s = \text{sorted}(s) \] where \(\text{sorted}(s)\) represents the string obtained by sorting the characters of \(s\) in non-decreasing order.

Example:

  • For the input "abc", since it is already in alphabetical order, the output should be VALID.
  • For the input "cba", since it is not in alphabetical order, the output should be INVALID.
  • For the input "ace", the characters are in order so the result is VALID.

You need to use the input format described below and provide the answer for each name on a new line.

inputFormat

The first line of input contains a single integer T (1 ≤ T ≤ 100), the number of names. The following T lines each contain a single non-empty string consisting of lowercase letters representing a name.

outputFormat

For each name, output a single line containing either VALID if the name's letters are in alphabetical order, or INVALID otherwise.

## sample
3
abc
cba
ace
VALID

INVALID VALID

</p>