#K55927. Balance the Animals
Balance the Animals
Balance the Animals
You are given a list of animals adopted from a shelter. Each animal is either a "CAT" or a "DOG". Your task is to determine whether the number of cats equals the number of dogs.
Formally, let \(N_{cat}\) be the number of cats and \(N_{dog}\) be the number of dogs. The answer is "BALANCED" if \(N_{cat} = N_{dog}\) and "UNBALANCED" otherwise.
Note that the input is provided via standard input (stdin) and the output should be printed to standard output (stdout).
Examples:
- For the input:
4
, the output should be
CAT
DOG
CAT
DOGBALANCED
. - For the input:
3
, the output should be
CAT
DOG
CATUNBALANCED
.
inputFormat
The first line contains an integer \(n\) (\(0 \le n \le 10^5\)) representing the number of animals. The next \(n\) lines each contain a single string which will be either "CAT" or "DOG".
outputFormat
Output a single line containing either "BALANCED" if the number of cats equals the number of dogs, or "UNBALANCED" otherwise.
## sample4
CAT
DOG
CAT
DOG
BALANCED