CF1574B.Combinatorics Homework

传统题 时间 2000 ms 内存 256 MiB 5 尝试 1 已通过 1 标签

Combinatorics Homework

You are given four integer values aa, bb, cc and mm.

Check if there exists a string that contains:

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

Input

The first line contains a single integer tt (1t1041 \le t \le 10^4) — the number of testcases.

Each of the next tt lines contains the description of the testcase — four integers aa, bb, cc and mm (1a,b,c1081 \le a, b, c \le 10^8; 0m1080 \le m \le 10^8).

Output

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 yEs, yes, Yes and YES will all be recognized as positive answer).

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.

Samples

3
2 2 1 0
1 1 1 1
1 2 3 2
YES
NO
YES

在线编程 IDE

建议全屏模式获得最佳体验