#C10099. Balanced Problem Set

    ID: 39266 Type: Default 1000ms 256MiB

Balanced Problem Set

Balanced Problem Set

In this problem, you are given the required and available counts of problems at three difficulty levels: easy, medium, and hard. A problem set is considered balanced if, for each difficulty level, the available count is at least the required count. Formally, the condition can be written in LaTeX as follows:

$$e2 \ge e1,\quad m2 \ge m1,\quad h2 \ge h1$$

Your task is to determine whether each problem set is balanced.

inputFormat

The input begins with an integer T representing the number of test cases. Each test case consists of a single line containing six space-separated integers: e1 e2 m1 m2 h1 h2, where:

  • e1 is the required number of easy problems and e2 is the available number of easy problems.
  • m1 is the required number of medium problems and m2 is the available number of medium problems.
  • h1 is the required number of hard problems and h2 is the available number of hard problems.

outputFormat

For each test case, output a single line containing either BALANCED if the available counts for each difficulty are at least the required counts, or UNBALANCED otherwise.

## sample
3
10 15 5 10 3 5
8 5 6 6 2 1
4 4 2 2 3 3
BALANCED

UNBALANCED BALANCED

</p>