#BS0000008. Tinh tinh đào hoa (The Playboy Chimp)
Tinh tinh đào hoa (The Playboy Chimp)
The Playboy Chimp
Source: UVa
Version: Phuoc Hung OJ Extended
Problem Statement
You are given heights in non-decreasing order. For each query height , find:
- the greatest height strictly smaller than ;
- the smallest height strictly greater than .
Heights equal to must not be selected. Print X whenever one side does not exist.
Input
The first line contains .
The second line contains the heights in non-decreasing order.
The third line contains .
The fourth line contains the query heights.
Output
For each query, print the nearest strictly smaller height and the nearest strictly greater height. Use X if one of them does not exist.
Subtasks
- Subtask 1 — 20%: .
- Subtask 2 — 30%: , .
- Subtask 3 — 50%: , , .
Examples
Input
4
1 4 5 7
4
4 6 8 10
Output
1 5
5 7
7 X
7 X
Explanation
For , the greatest height below is , and the smallest height above is . A height equal to is excluded.