#C1590. Banana Consumption Rearrangement

    ID: 44812 Type: Default 1000ms 256MiB

Banana Consumption Rearrangement

Banana Consumption Rearrangement

You are given a list of banana consumption numbers for exactly 5 consecutive days. Your task is to determine if it is possible to rearrange the consumption values so that no two consecutive days have the same number of bananas consumed. In other words, no adjacent numbers in the rearranged sequence should be equal.

A necessary and sufficient condition for the rearrangement is that the maximum frequency among the 5 numbers does not exceed $$\left\lceil\frac{5}{2}\right\rceil$$.

If the maximum frequency is greater than $$\frac{5+1}{2}$$ (which is equivalent to $$\left\lceil\frac{5}{2}\right\rceil$$), then it is impossible to obtain such a rearrangement, and you should output NO. Otherwise, output YES.

The input begins with an integer T representing the number of test cases. Each test case consists of 5 integers, separated by spaces, describing the banana consumption over 5 days. Process each test case independently.

inputFormat

The first line contains an integer T (the number of test cases). Each of the following T lines contains exactly 5 space-separated integers.

outputFormat

For each test case, output a single line containing either YES if a valid rearrangement is possible, or NO otherwise.

## sample
1
1 2 3 3 4
YES

</p>