Binary Sequence
Tag(s):

## Ad-Hoc, Easy, Getting Started, Number, Python

Problem
Editorial
Analytics

Given four integers $x, y, a$ and $b$. Determine if there exists a binary string having $x$ 0's and $y$ 1's such that the total number of subsequences equal to the sequence "01" in it is $a$ and the total number of subsequences equal to the sequence "10" in it is $b$.

A binary string is a string made of the characters '0' and '1' only.

A sequence $a$ is a subsequence of a sequence $b$ if $a$ can be obtained from $b$ by deletion of several (possibly, zero or all) elements.

Input Format

The first line contains a single integer $T$ ($1 \le T \le 10^5$), denoting the number of test cases.

Each of the next $T$ lines contains four integers $x$, $y$, $a$ and $b$ (($1 \le x, y \le 10^5$, ($0 \le a, b \le 10^9$)), as described in the problem.

Output Format

For each test case, output "Yes'' (without quotes) if a string with given conditions exists and "No'' (without quotes) otherwise.

SAMPLE INPUT
3
3 2 4 2
3 3 6 3
3 3 4 3

SAMPLE OUTPUT
Yes
Yes
No

Explanation

When x, y, a and b are 3, 2, 4 and 2 respectively, string 00110 is a valid string. So answer is Yes

When x, y, a and b are 3, 3, 4 and 3 respectively, we can't find any valid string. So answer is No.

Time Limit: 2.0 sec(s) for each input file.
Memory Limit: 256 MB
Source Limit: 1024 KB
Marking Scheme: Marks are awarded when all the testcases pass.
Allowed Languages: Bash, C, C++, C++14, Clojure, C#, D, Erlang, F#, Go, Groovy, Haskell, Java, Java 8, JavaScript(Rhino), JavaScript(Node.js), Julia, Kotlin, Lisp, Lisp (SBCL), Lua, Objective-C, OCaml, Octave, Pascal, Perl, PHP, Python, Python 3, R(RScript), Racket, Ruby, Rust, Scala, Swift, Swift-4.1, TypeScript, Visual Basic

## CODE EDITOR

Initializing Code Editor...

## This Problem was Asked in Challenge Name

May Easy' 19

OTHER PROBLEMS OF THIS CHALLENGE
• Math > Basic Math
• Algorithms > Dynamic Programming
• Algorithms > Graphs
• Data Structures > Advanced Data Structures
• Data Structures > Advanced Data Structures