All Tracks Basic Programming Implementation Basics of Implementation Problem

Chessboard and Dominoes
Tag(s):

Easy, Implementation

Problem
Editorial
Analytics

There is a 8x8 chessboard in which two positions are cut-off (i.e not available for placing any piece). You are given 31 dominos , and a single domino can cover exactly two squares. Given the two positions which are cut-off , find if it is possible to cover the entire board with 31 exactly dominos so that no vacant square exists.

Chessboard

Here is the view of chess board with rows from 1-8 and columns from A-H.

Input

The first line of input contains T , the number of test cases.

The first line of each testcase contains X and Y , where CHESS[X][Y] is cutoff.

The second line of each testcase contains A and B , where CHESS[A][B] is cutoff.

OUTPUT

For each testcase , output "YES" if possible else "NO" on a new line.

SAMPLE INPUT
2
5 e
5 d
1 a
8 h
SAMPLE OUTPUT
YES
NO
Explanation

For the first test case , the cut-off squares are CHESS[5][E] and CHESS[5][D] which are shown as red squares in the picture below. Sample picture

31 dominos are placed without any extra space left , so we output "YES".

Time Limit: 1.25 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: 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, Visual Basic

CODE EDITOR

Initializing Code Editor...
Your Rating:

Contributor

Notifications
View All Notifications