Under construction

Still being built. Things may change

A Packing Problem

Interview

Time limit2sMemory limit512 MB

Summary
Given a rectangle and two circles, decide whether both circles fit inside the rectangle without overlapping, allowing tangency.
Level

Medium6 of 10

Topics
Geometry, Math, Implementation, Brute force
Solved
No attempts yet

Problem

Miguel packs cans into boxes with a rectangular base. Every can is a right circular cylinder, and the two cans can have different heights. The height of the box is always greater than the height of either can.

Miguel wants to put two cans, whose radii may differ, into one box. The packing is good if both cans stand upright (looking into the box from above you see the two circular bases) and neither can sits on top of the other. Every other arrangement is bad. The two cans may touch each other on the sides, and a can may touch a wall of the box.

In other words, the packing is good exactly when both base circles lie inside the rectangular base of the box and the interiors of the two circles do not overlap. Two circles that meet at a single point do not count as overlapping.

Given the two side lengths of the base of the box and the radii of the two cans, decide whether a good packing exists.

Input

The first line contains the number of test cases TT.

Each of the next TT lines contains four integers LL, WW, R1R_1, R2R_2 separated by single spaces. LL and WW are the side lengths of the base of the box, and R1R_1 and R2R_2 are the radii of the two cans to be packed.

Constraints

  • 1≤T≤1051 \le T \le 10^5
  • 1≤L≤1041 \le L \le 10^4
  • 1≤W≤1041 \le W \le 10^4
  • 1≤R1≤1041 \le R_1 \le 10^4
  • 1≤R2≤1041 \le R_2 \le 10^4

Output

For each test case, print PACKING GOOD on its own line if a good packing exists, and PACKING BAD otherwise.

Hint

The first test case of the first example can be packed like this.

Examples2

  1. Example 1

    Input
    2
    7 10 3 2
    4 7 2 2
    
    Expected output
    PACKING GOOD
    PACKING BAD
    
  2. Example 2

    Input
    3
    4 4 1 1
    10 6 2 3
    1 1 1 1
    
    Expected output
    PACKING GOOD
    PACKING GOOD
    PACKING BAD