Pop-Up Orientation

3.4

16 votes
Basic Programming, Basics of Implementation, Easy, Implementation
Problem

In web application development, it is often required to draw a pop-up window on top of a web page when the user clicks on an icon on the page that brings up the pop-up.
You are given a web page with width x and height y, a pop-up window with width l and height m, and an icon at distance a from the left of the page and distance b from the bottom of the page.
Your program should output the orientation in which the pop-up can be rendered fully, relative to the icon, within the page dimensions. The orientation of pop up should be such that it lies completely within the page.
There are 4 possible orientations: bottom-right, bottom-left, top-right and top-left, in the same order of preference. In other words, you should first attempt to render the pop-up bottom-right, and if that is not possible, try bottom-left, and so on.

Note: Icon location and pop-up size are such that the pop-up can always be fully rendered within the page.

Input:
First line contains an integer, T, denoting the number of test cases.
Next T lines contain six space separated integers each, x, y, l, m, a and b.

Output:
For each test case, print the orientation in which the pop-up can be rendered fully, relative to the icon, within the page dimensions.

Constraints:
1T105
1x3000
1y3000
1lx
1my
0ax
0by
There is always an orientation possible such that the pop-up will lie within the page.

Sample Input
4
1024 768 200 300 200 600
1024 768 200 300 1000 600
1024 768 200 300 200 200
1024 768 200 300 900 100

Sample Output
bottom-right
bottom-left
top-right
top-left
Time Limit: 1
Memory Limit: 256
Source Limit:
Explanation

In the figure below the black dot is denoting the position of the icon.

enter image description here

Editor Image

?