Not an official ACM page
[Problem 6 | 1997 ACM North-Central Regionals problem set | Ed's Programming Contest Problem Archive | my home page]

1997-98 North Central Regionals

Doing Windows -- Problem 5

The screen of monitors on computer systems are rectangles. The aspect ratio of a screen is its width divided by its height. This term can also be applied to rectangular windows that may appear on the monitor's screen, where it is defined as the width of the window divided by its height. For this problem we assume the dimensions of a monitor's screen and its windows are measured in integral numbers of pixels, the individual dots (arranged in a rectangular grid) that comprise and image.

Suppose your windowing software only allows windows to be resized in such a way that their aspect ratios are unmodified. For example, a window with a width of 150 pixels and a height of 100 pixels (and an espect ratio of 150/100, or 1.5) can be resized so its width is 225 pixels and its height is 150 pixels (the aspect ratio remains unchanged, at 225/150, or 1.5), but a width of 224 and a height of 150 is not allowed, since that would change the aspect ratio. Each window can be moved to an arbitrary location on the screen, but the entire window must remain visible on the screen.

Given the size of a screen and the initial sizes of four different windows (as integer values for width and height), is it possible to resize (and relocate) the four windows so they completely cover the screen without overlapping each other? That's the question you are to answer in this problem.

For example, consider a square screen with four square windows. The aspect ratio for each of these is exactly 1. We are permitted to resize each of the four windows so they would completely fill the screen without overlapping. This case is illustrated by the first data set in the Sample Input, below.

Input

Input will consist of one or more data sets followed by a pair of zeroes. Each data set will contain five pairs of integers. The first pair (Ws, Hs) specifies the width and height of the screen. The four remaining pairs (Wi, Hi, for i = 1 to 4) specify the initial sizes of the windows.

Output

Output should have one line for each input data set. The line should contain the input data set number (starting with 1) followed by the word Yes if the screen can be completely covered by the (possibly resized and relocated) windows with no overlap, or No if it cannot be so covered.

Sample Input

400 400   10 10  35 35   15 15   100 100
200 300   10 10  20 20   30 45   40 60
200 250   10 10  20 20   30 45   40 60

0 0

Expected Output

Set 1: Yes
Set 2: No
Set 3: Yes

Judge's Input Data and Expected Output

Sample Solution


This page maintained by Ed Karrels.
Last updated December 10, 1999