#K55927. Balance the Animals

    ID: 30084 Type: Default 1000ms 256MiB

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
    CAT
    DOG
    CAT
    DOG
    , the output should be BALANCED.
  • For the input: 3
    CAT
    DOG
    CAT
    , the output should be UNBALANCED.

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.

## sample
4
CAT
DOG
CAT
DOG
BALANCED