Business Cards
Time limit1sMemory limit512 MB
Decide whether a c x d sheet can be tiled exactly by axis-aligned a x b rectangles that may be rotated, for up to 1e5 cases.
- Level
Medium7 of 10
- Topics
- Math, Number theory, Geometry, Implementation
- Solved
- No attempts yet
Problem
Running a paper shop is not an easy job, especially with demanding customers. Today the customers brought their own rectangular sheets of paper and asked you to cut each sheet into rectangular business cards of a fixed size. On top of that, they insist that all of the paper is used — not even a tiny scrap may be left over. The clever idea of cutting the sheet into very small pieces and then gluing them together into the desired cards is not allowed. Each card may be placed in either orientation (that is, it may be rotated by ).
An example of a paper sheet divided into cards is shown below.

Input
The first line contains the number of test cases (). Each of the next lines contains four integers , , , (): are the dimensions of each business card, and are the dimensions of the paper sheet.
Output
For each test case, output a single line containing YES if the whole sheet can be divided into business cards, and NO otherwise.