This page is still under construction.

Parts of this page are still being built. What you see may change.

Dalia

Time limit1sMemory limit256 MB

Summary
Decide for each test case whether a knight moves from the start square to the target square in exactly one legal move.
Level

Easy1 of 10

Topics
Implementation
Solved
No attempts yet

Problem

The ICPC community feels like an extended family spread across the world. One reason for that feeling is that the contest organizers, the judges and the coaches bring their families to the contest sites, so seeing children at a contest site is not unusual. One of the kids who came to the 2013 ICPC was Mohamed, the young son of Dalia El-Hefny. Dalia works on the fund raising team of the ACPC and has been a very close friend of Fegla since 1998. While wandering around the IBM Chill Zone, Mohamed came across people playing chess and asked them to teach him how to play, so one of them gave him an introductory book about chess.

One section of that book covers the knight and its complex movement. To teach the reader, the book fills many pages with a starting position and an ending position for a knight on a very large board, and asks the reader to decide whether the knight can reach the ending position from the starting position in exactly one move. Mohamed has asked you to write a program that answers the questions in the book.

Input

The first line contains a single integer TT, the number of test cases (1≤T≤1001 \le T \le 100).

Each of the next TT lines holds one test case as five integers nn, r1r_1, c1c_1, r2r_2, c2c_2. The chess board has size n×nn \times n (2≤n≤1092 \le n \le 10^9). (r1,c1)(r_1, c_1) is the starting position of the knight and (r2,c2)(r_2, c_2) is the ending position (1≤r1,c1,r2,c2≤n1 \le r_1, c_1, r_2, c_2 \le n).

Output

Print one line for each test case. Print Case i: YES if the knight can reach the ending position in exactly one move, and Case i: NO if it cannot. Here ii is the test case number, counted from 1.

Hint

Rows are numbered from 1 to nn from the top to the bottom and columns are numbered from 1 to nn from the left to the right. A knight at position (r,c)(r, c) can move only to one of the following eight positions, and only if that position lies inside the board.

(r−1,c+2)(r-1, c+2), (r−1,c−2)(r-1, c-2), (r+1,c+2)(r+1, c+2), (r+1,c−2)(r+1, c-2), (r−2,c+1)(r-2, c+1), (r−2,c−1)(r-2, c-1), (r+2,c+1)(r+2, c+1), (r+2,c−1)(r+2, c-1)

About the IBM Chill Zone: a relaxing, fun way to unwind nightly with old and new friends at the ACM-ICPC World Finals is to stop by the IBM Chill Zone. It is a great way to take part in interactive games and interesting conversation with innovative IBMers and attendees from all over the world, and the IBM Chill Zone is always a favorite for everyone.

Examples4

  1. Example 1

    Input
    2
    4 1 2 2 4
    5 1 1 3 3
    
    Expected output
    Case 1: YES
    Case 2: NO
    
  2. Example 2

    Input
    4
    2 1 1 2 2
    2 1 1 1 2
    2 2 1 1 1
    2 2 2 1 2
    
    Expected output
    Case 1: NO
    Case 2: NO
    Case 3: NO
    Case 4: NO
    
  3. Example 3

    Input
    8
    5 3 3 2 5
    5 3 3 2 1
    5 3 3 4 5
    5 3 3 4 1
    5 3 3 1 4
    5 3 3 1 2
    5 3 3 5 4
    5 3 3 5 2
    
    Expected output
    Case 1: YES
    Case 2: YES
    Case 3: YES
    Case 4: YES
    Case 5: YES
    Case 6: YES
    Case 7: YES
    Case 8: YES
    
  4. Example 4

    Input
    1
    3 1 1 2 3
    
    Expected output
    Case 1: YES