Solar Panels

No attempts yetTime limit1sMemory limit256 MB

Problem

Byteasar decided to invest in renewable energy and opened a solar panel factory. Within a few days nn clients came in. Each client ordered one rectangular panel and gave a range for its width and a range for its height.

A panel is filled with square photovoltaic cells. A cell side length can be any positive integer, but all cells in one panel have the same side length. The larger the cells, the more efficient the panel, so for every order Byteasar wants the largest cell side length he can use.

For the ii-th order the width is chosen as an integer in [smin,smax][s_{min}, s_{max}] and the height as an integer in [wmin,wmax][w_{min}, w_{max}]. A panel of width WW and height HH can be filled with cells of side length kk exactly when kk divides both WW and HH.

Input

The first line contains one integer nn (1n10001 \le n \le 1000), the number of ordered panels.

Each of the next nn lines describes one panel and contains four integers smins_{min}, smaxs_{max}, wminw_{min}, wmaxw_{max} separated by single spaces (1sminsmax1091 \le s_{min} \le s_{max} \le 10^9, 1wminwmax1091 \le w_{min} \le w_{max} \le 10^9). In order, they are the minimum width, the maximum width, the minimum height, and the maximum height of the ii-th panel.

Output

Print exactly nn lines. Line ii contains the largest cell side length that the ii-th panel can be made of.

Hint

In the first example Byteasar builds panels of size 8×88 \times 8 (one cell), 7×147 \times 14 (two cells), 4×224 \times 22 or 6×226 \times 22 (22 or 33 cells), and 5×205 \times 20 (four cells).