#C2058. City Construction

    ID: 45332 Type: Default 1000ms 256MiB

City Construction

City Construction

You are given a grid with n rows and m columns. Your task is to build a city by placing exactly x buildings on the grid while ensuring that no row or column contains more than p buildings.

In mathematical terms, the following conditions must be met:

  • $$x \leq n \times m$$
  • $$x \leq \min(n, m) \times p$$

Determine whether it is possible to construct the city under these constraints. Output YES if it is possible, and NO otherwise.

inputFormat

The first line contains a single integer T representing the number of test cases. Each of the following T lines contains four space-separated integers: n (number of rows), m (number of columns), x (number of buildings), and p (maximum buildings allowed in any row or column).

outputFormat

For each test case, output one line containing either YES if the city can be constructed under the constraints, or NO if it cannot.

## sample
4
3 3 4 2
2 2 3 1
4 4 16 4
5 5 10 3
YES

NO YES YES

</p>