Under construction

Still being built. Things may change

Have a Nice Day

Time limit1sMemory limit128 MB

Summary
For each date, check that every digit occurring in day, month, and year appears equally often, and that day, month, and the two year halves split into two equal-sum groups.
Level

Medium4 of 10

Topics
Implementation, Brute force, Math, Simulation
Solved
No attempts yet

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,…,90, \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 19571957 this is 1919),
    • the right half of the year — the number made from its last two digits (for 20002000 this is 00).

    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=4916 + 5 + 28 = 49, so {49}\{49\} and {16,5,28}\{16, 5, 28\} are two groups with the same sum.

Input

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

Output

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

Examples2

  1. Example 1

    Input
    4
    16 5 4928
    14 12 2747
    11 11 1111
    3 3 2014
    
    Expected output
    yes
    no
    yes
    no
    
  2. Example 2

    Input
    1
    9 4 1023
    
    Expected output
    yes