Have a Nice Day

No attempts yetTime limit1sMemory limit128 MB

Problem

Rumour has it that the P versus NP question has finally been settled: the two classes are not equal. That means hard problems such as the Traveling Salesman Problem will stay hard forever, and essentially only brute force can crack them. There is nothing you can do about that.

In view of this, the government has declared that on certain days no one may work on such hard problems anymore. Instead, one must concentrate on easier matters. These days are called nice. Naturally, the rule that decides whether a given date is nice must itself be easy. So far no one has found such a rule. Can you?

A date is written as three numbers, day month year, using the digits $0, \dots, 9$. A date is nice when both of the conditions below hold.

  1. Balanced digits. Look at every digit that appears when the date is written out (the day, the month, and the four-digit year). Each digit that occurs must occur the same number of times as every other digit that occurs.

  2. Splittable. Form four numbers from the date:

    • the day,
    • the month,
    • the left half of the year — the number made from its first two digits (for $1957$ this is $19$),
    • the right half of the year — the number made from its last two digits (for $2000$ this is $0$).

    The date is splittable if these four numbers can be divided into two groups with equal sum.

For example, 16 5 4928 is nice: every digit occurs exactly once, and $16 + 5 + 28 = 49$, so ${49}$ and ${16, 5, 28}$ are two groups with the same sum.

Input

The first line contains a single integer $T$: the number of test cases. Each of the next $T$ lines describes one date with three integers $D$, $M$, and $Y$ separated by single spaces, satisfying $1 \le D \le 31$, $1 \le M \le 12$, and $1000 \le Y \le 9999$ — the day, month, and year of a valid date. There are no leading zeros; for example, June is written as $6$, not $06$.

Output

For each test case, print yes if the date is nice and no otherwise. Print each answer on its own line.