## Hungry

View as PDF

Points: 5 (partial)
Time limit: 2.0s
Memory limit: 64M

Author:
Problem type

Jason is feeling rather hungry today. As such, he decides to raid his fridge. Upon arriving at his fridge, he realized that he could either eat his favourite snacks, or the most filling snacks. Help Jason decide on what he should eat by listing the foods from least tasty to most tasty, and from least filling to most filling.

#### Input Specification

The first line has an integer , the number of foodstuffs in Jason's fridge.
The next lines will have two integers, and , how filling and tasty the foodstuff is, respectively. A foodstuff is more filling than foodstuff if , and more tasty if .

It is guaranteed that no two foodstuffs will be equally filling or tasty.

#### Output Specification

The output should consist of lines.
The first line should contain integers, with the integer being the least filling.
The second line should also contain integers, with the integer being the least tasty.

#### Sample Input 1

5
1 5
2 4
3 3
4 2
5 1

#### Sample Output 1

1 2 3 4 5
5 4 3 2 1

#### Sample Input 2

5
5 3
3 5
6 7
1 4
8 1

#### Sample Output 2

4 2 1 3 5
5 1 4 2 3