We use cookies to ensure you have the best browsing experience on our website. Please read our cookie policy for more information about how we use cookies.
  • Hackerrank Home
  • Prepare
    NEW
  • Certify
  • Compete
  • Career Fair
  • Hiring developers?
  1. Prepare
  2. Mathematics
  3. Fundamentals
  4. Possible Path

Possible Path

Problem
Submissions
Leaderboard
Discussions
Editorial

Adam is standing at point in an infinite 2D grid. He wants to know if he can reach point or not. The only operation he can do is to move to point from some point . It is given that he can move to any point on this 2D grid, i.e., the points having positive or negative (or ) co-ordinates.

Tell Adam whether he can reach or not.

Input Format

The first line contains an integer, , followed by lines, each containing space-separated integers i.e. , , and .

Constraints

Output Format

For each test case, display YES or NO that indicates if Adam can reach or not.

Sample Input

3
1 1 2 3
2 1 2 3
3 3 1 1

Sample Output

YES
YES
NO

Explanation

  1. (1,1) -> (2,1) -> (2,3).

Author

amititkgp

Difficulty

Easy

Max Score

20

Submitted By

12487

Need Help?


View discussions
View editorial
View top submissions

rate this challenge

MORE DETAILS

Download problem statement
Download sample test cases
Suggest Edits

Choose a translation


  • Blog
  • Scoring
  • Environment
  • FAQ
  • About Us
  • Support
  • Careers
  • Terms Of Service
  • Privacy Policy
  • Request a Feature