Algorithm


A. Fair Playoff
time limit per test
2 seconds
memory limit per test
256 megabytes
input
standard input
output
standard output

Four players participate in the playoff tournament. The tournament is held according to the following scheme: the first player will play with the second, and the third player with the fourth, then the winners of the pairs will play in the finals of the tournament.

It is known that in a match between two players, the one whose skill is greater will win. The skill of the i-th player is equal to si�� and all skill levels are pairwise different (i. e. there are no two identical values in the array s).

The tournament is called fair if the two players with the highest skills meet in the finals.

Determine whether the given tournament is fair.

Input

The first line contains a single integer t (1t1041≤�≤104) — the number of test cases.

A single line of test case contains four integers s1,s2,s3,s4�1,�2,�3,�4 (1si1001≤��≤100) — skill of the players. It is guaranteed that all the numbers in the array are different.

Output

For each testcase, output YES if the tournament is fair, or NO otherwise.

Example
input
Copy
4
3 7 9 5
4 5 6 9
5 3 8 1
6 5 3 2
output
Copy
YES
NO
YES
NO
Note

Consider the example:

  1. in the first test case, players 22 and 33 with skills 77 and 99 advance to the finals;
  2. in the second test case, players 22 and 44 with skills 55 and 99 advance to the finals. The player with skill 66 does not advance, but the player with skill 55 advances to the finals, so the tournament is not fair;
  3. in the third test case, players 11 and 33 with skills 55 and 88 advance to the finals;
  4. in the fourth test case, players 11 and 33 with skills 66 and 33 advance to the finals. The player with skill 55 does not advance, but the player with skill 33 advances to the finals, so the tournament is not fair.

 



 

Code Examples

#1 Code Example with C++ Programming

Code - C++ Programming

#include<bits/stdc++.h>
using namespace std;


#define ll long long
#define endl '\n'
#define debug(n) cout<<(n)<<endl;
const ll INF = 2e18 + 99;

int main(){
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);

  int t;
  cin>>t;
  while(t--){
    int a, b, c, d;
    cin>a>>b>>c>>d;
    if(max(a, b) > min(c, d) && max(c, d) > min(a, b)){
      cout<<"YES"<<endl;
      continue;
    }
    cout<<"NO"<<endl;
  }

}
Copy The Code & Try With Live Editor

Input

x
+
cmd
4
3 7 9 5
4 5 6 9
5 3 8 1
6 5 3 2

Output

x
+
cmd
YES
NO
YES
NO
Advertisements

Demonstration


Codeforcess Solution 1535-A A. Fair Playoff ,C++, Java, Js and Python,1535-A,Codeforcess Solution

Previous
Codeforces solution 1080-B-B. Margarite and the best present codeforces solution
Next
CodeChef solution DETSCORE - Determine the Score CodeChef solution C,C+