#CCBCHMOT0000013. Góc phần tư (Quadrant)
Góc phần tư (Quadrant)
Quadrant
Source: beecrowd
Version: Phuoc Hung OJ Extended
Problem Statement
Read integer coordinate pairs in order. For pairs with both coordinates nonzero, print the quadrant: I (+,+), II (-,+), III (-,-), IV (+,-). Stop at the first pair with x=0 or y=0, without printing for that pair.
Input
Each line contains an integer pair x,y; a terminating pair has x=0 or y=0.
Output
One line per nonterminating point: primeiro, segundo, terceiro or quarto for quadrants I–IV.
Subtasks
- Subtask 1 (20%): The first pair is terminating.
- Subtask 2 (30%): At most 10 nonterminating points; coordinate magnitude <= 10.
- Subtask 3 (50%): At most 1000 nonterminating points; coordinate magnitude <= 1000000.
Examples
Example 1
Input
2 2
3 -2
-8 -1
-7 1
0 2
Output
primeiro
quarto
terceiro
segundo
Explanation
The four nonzero pairs belong to quadrants I, IV, III and II, respectively. The pair (0,2) terminates input.
Example 2
Input
0 0
Output
Explanation
The first pair is the sentinel, so output is empty.