# Description

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 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.
n组询问，每次问smin<=x<=smax, wmin<=y<=wmax时gcd(x, y)的最大值。

# Code

#include <stdio.h>
#include <string.h>
#include <algorithm>
#define rep(i,st,ed) for (int i=st;i<=ed;++i)
#define drp(i,st,ed) for (int i=st;i>=ed;--i)
#define min(x,y) ((x)<(y)?(x):(y))

int x=0,v=1; char ch=getchar();
for (;ch<'0'||ch>'9';v=(ch=='-')?(-1):(v),ch=getchar());
for (;ch<='9'&&ch>='0';x=x*10+ch-'0',ch=getchar());
return x*v;
}

inline void writeln(int x){
char ch[21]={}; int i=0;
if (x<0) putchar('-');
do {ch[++i]='0'+x%10;} while (x/=10);
for (;i;) putchar(ch[i--]);
putchar('\n');
}

int main(void) {
if (b>d) std:: swap(a,c),std:: swap(b,d);
int ans=0,l1,l2,r1,r2;
for (int i=1,last;i<=b;i=last+1) {
last=min(b/(b/i),d/(d/i));
if (i<=a) last=min(last,a/(a/i));
if (i<=c) last=min(last,c/(c/i));
l1=a/i,r1=b/i;
l2=c/i,r2=d/i;
if (l1>=r1||l2>=r2) continue;
ans=last;
}
writeln(ans);
}
return 0;
}