QOJ.ac

QOJ

Time Limit: 3 s Memory Limit: 128 MB Total points: 100 Difficulty: [show]

#309. Solar Panels

統計

Having decided to invest in renewable energy, Byteasar started a solar panels factory. It appears that he has hit the gold as within a few days $n$ clients walked through his door. Each client has ordered a single rectangular panel with specified width and height ranges.

The panels consist of square photovoltaic cells. The cells are available in all integer sizes, i.e., with the side length integer, but all cells in one panel have to be of the same size. The production process exhibits economies of scale in that the larger the cells that form it, the more efficient the panel. Thus, for each of the ordered panels, Byteasar would like to know the maximum side length of the cells it can be made of.

Input Format

The first line of the standard input contains a single integer $n$ ($1 ≤ n ≤ 1\,000$): the number of panels that were ordered. The following n lines describe each of those panels: the $i$-th line contains four integers $s_{min}$, $s_{max}$, $w_{min}$, $w_{max}$ ($1 ≤ s_{min} ≤ s_{max} ≤ 10^{9}$, $1 ≤ w_{min} ≤ w_{max} ≤ 10^{9}$), separated by single spaces; these specify the minimum width, the maximum width, the minimum height, and the maximum height of the i-th panel respectively.

In tests worth $75\%$ of the total score, $s_{max},w_{max} ≤ 10^{7}$ holds for each panel. In their subset worth $20\%$ of the total score, $n ≤ 10$ holds in addition.

Output Format

Your program should print exactly $n$ lines to the standard output. The $i$-th line is to give the maximum side length of the cells that the $i$-th panel can be made of.

Example

Input

4
3 9 8 8
1 10 11 15
4 7 22 23
2 5 19 24

Output

8
7
2
5

Byteasar will produce four solar panels of the following sizes: 8x8(a single cell), 7x14(two cells), 4x22 or 6x22 (22 or 33 cells respectively), and 5x20 (four cells).

About Issues

We understand that our problem archive is not perfect. If you find any issues with the problem, including the statement, scoring configuration, time/memory limits, test cases, etc.

You may use this form to submit an issue regarding the problem. A problem moderator will review your issue and proceed it properly.

STOP! Before you submit an issue, please READ the following guidelines:

  1. This is not a place to publish a discussion, editorial, or requests to debug your code. Your issue will only be visible by you and problem moderators. Other users will not be able to view or reply your issues.
  2. Do not submit duplicated issues. If you have already submitted one, please wait for an moderator to review it. Submitting multiple issues will not speed up the review process and might cause your account to be banned.
  3. Issues must be filed in English or Chinese only.
  4. Be sure your issue is related to this problem. If you need to submit an issue regarding another problem, contest, category, etc., you should submit it to the corresponding page.

Active Issues 0

No issues in this category.

Closed/Resolved Issues 0

No issues in this category.