#C1921. Balanced Binary Strings

    ID: 45180 Type: Default 1000ms 256MiB

Balanced Binary Strings

Balanced Binary Strings

You are given a list of binary strings. For each string, you need to determine whether it is balanced or unbalanced. A binary string is considered balanced if it contains an even number of the digit 1; otherwise, it is unbalanced.

Your task is to read the input from standard input (stdin) and produce the output on standard output (stdout) as specified below.

Note: In this problem, the input first contains an integer t representing the number of binary strings. Each of the following t lines contains a binary string. For each binary string, print the result on a separate line.

The outcome for each binary string should be:

  • balanced if the number of 1s is even.
  • unbalanced if the number of 1s is odd.

The solution may use the following mathematical condition in LaTeX format: $$\text{result} = \begin{cases}\text{balanced} & \text{if } (\#1's \mod 2 = 0)\\\text{unbalanced} & \text{otherwise} \end{cases}$$

inputFormat

The input is given from standard input (stdin) and has the following format:

 t
 s1
 s2
 ...
 st

Here, t (an integer) represents the number of binary strings, followed by t lines, each containing a binary string.

outputFormat

For each binary string, output a single line on standard output (stdout) containing either balanced or unbalanced based on whether the number of 1's in the string is even or odd, respectively.

## sample
4
101010
1111
100000
101
unbalanced

balanced unbalanced balanced

</p>