11498-division of Nlogonia
Time limit:1.000 seconds
Http://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&category=24&page=show_problem &problem=2493
The Problem
After centuries of hostilities and skirmishes between the Four nations living into the land generally known as Nlogonia, and Years of negotiations involving diplomats, politicians and the armed forces of all interested, with parties by UN, NATO, G7 and SBC, it was in last agreed by all the way to end of dispute, dividing the land into four independent ter Ritories.
It was agreed this one point, called Division Point, with coordinates established in the negotiations, would define the CO Untry Division, in the following way. Two lines, both containing the division point, one on the North-south direction and one in the east-west direction, would Be drawn on the map and dividing the land into four new countries. Starting from the Western-most, Northern-most Quadrant, in clockwise direction, the new countries'll be called Northwest Ern Nlogonia, northeastern Nlogonia, southeastern Nlogonia and southwestern Nlogonia.
The UN determined that "a page in the" Internet should exist so this inhabitants could check in which of the countries T Heir homes are. You are have been hired to help implementing the system.
The Input
The input contains several test cases. The A test case contains one integer K indicating the number of queries that would be made (0 < k≤103). The second line of "a test case" contains two integers Nand M representing the coordinates of the division point ( -104 < N, M < 104). Each of the K following lines contains two integers X and Y representing the coordinates of a residence ( -104≤x, y≤104 ).
The end of the input was indicated by a line containing only the number zero.
The Output
For each test case in the input your program must print one line containing:
The word divisa (means border in Portuguese) if the residence are on one of the border lines (North-south or east-west);
NO (means NW in Portuguese) if the residence was in northwestern Nlogonia;
NE if the residence is in northeastern Nlogonia;
SE if the residence is in southeastern Nlogonia;
So (means SW-Portuguese) if the residence is in southwestern Nlogonia.