Combinatorics Homework codeforces solution- You are given four integer values aa, bb, cc and mm. Check if there exists a string that contains: aa letters ‘A’;

Combinatorics Homework solution codeforces

You are given four integer values aabbcc and mm.

Check if there exists a string that contains:

  • aa letters ‘A‘;
  • bb letters ‘B‘;
  • cc letters ‘C‘;
  • no other letters;
  • mm pairs of adjacent equal letters (mm such positions ii that the ii-th letter is equal to the (i+1)(i+1)-th one).

Combinatorics Homework solution codeforces

The first line contains a single integer tt (1t1041≤t≤104) — the number of testcases.

Each of the next tt lines contains the description of the testcase — four integers aabbcc and mm (1a,b,c1081≤a,b,c≤1080m1080≤m≤108).

Combinatorics Homework solution codeforces

For each testcase print “YES” if there exists a string that satisfies all the requirements. Print “NO” if there are no such strings.

You may print every letter in any case you want (so, for example, the strings yEsyesYes and YES will all be recognized as positive answer).

Example

input

Copy
3
2 2 1 0
1 1 1 1
1 2 3 2

output

Copy
YES
NO
YES
Note

In the first testcase strings “ABCAB” or “BCABA” satisfy the requirements. There exist other possible strings.

In the second testcase there’s no way to put adjacent equal letters if there’s no letter that appears at least twice.

In the third testcase string “CABBCC” satisfies the requirements. There exist other possible strings.

Leave a Reply

Your email address will not be published. Required fields are marked *

*