Movement's direction X76609


Statement
 

pdf   zip

thehtml

Given two points (x1, y1) and (x2, y2) in a two-dimensional plane, if we move in a straight line from the first to the second point we advance in one of the following 8 directions: N (north), S (south), E (east), W (west), NE (northeast), NW (northwest), SE (southeast), SW (southwest). For example:

  • If we move from (0, 0) to (0, 5) we advance in the N direction;
  • If we move from (0, 5) to (0, 0) we advance in the S direction;
  • If we move from (0, 0) to (3, 4) we advance in the NE direction;
  • If we move from (3, 4) to (0, 0) we advance in the SW direction.

Given a sequence of pairs of points, we want to know, for each pair, the direction in which we move going from the first to the second point.

Input

The input starts with a non-negative integer n. Then, it follows a sequence of n quartets of integers x1 y1 x2 y2 representing the pair of points (x1, y1) and (x2, y2). Assume that (x1, y1) and (x2, y2) are different.

Output

For each pair of points (x1, y1) and (x2, y2) in the input sequence, the program outputs the direction in which we move when going from (x1, y1) to (x2, y2). Follow the format of the examples.

Public test cases
  • Input

    8
    0 0 0 5
    0 5 0 0
    0 0 3 4
    3 4 0 0
    -2 -3 1 -3
    2 4 -1 4
    -1 -1 0 -5
    3 -2 -1 -1

    Output

    N
    S
    NE
    SO
    E
    O
    SE
    NO
    
  • Input

    0

    Output

    
            
                                
  • Information
    Author
    Emma Rollón
    Language
    English
    Translator
    Original language
    Catalan
    Other languages
    Catalan Spanish
    Official solutions
    C++
    User solutions
    C++