func_code_string: #include <bits/stdc++.h>   using namespace std;   const int N = 1e5 + 9;   long long a, b, n, dv[N], l, r, sz;   long long bs(long long l, long long r) {     long long bas = 0;     long long son = sz + 1;     while (bas + 1 < son) {       long long orta = bas + son >> 1;       if (dv[orta] < l)         bas = orta;       else if (dv[orta] > r)         son = orta;       else if (dv[orta] <= r and dv[orta] >= l)         bas = orta;     }     return (dv[bas] < l or dv[bas] > r) ? -1 : dv[bas];   }   int main() {     cin >> a >> b >> n;     for (long long i = 1; i * i <= max(a, b); i++) {       if (a % i == 0 and b % i == 0) {         dv[++sz] = i;         if (b % (a / i) == 0 and i * i != max(a, b)) dv[++sz] = a / i;         if (a % (b / i) == 0) dv[++sz] = b / i;       } else if (a % (b / i) == 0 and b % i == 0)         dv[++sz] = b / i;       else if (b % (a / i) == 0 and a % i == 0)         dv[++sz] = a / i;     }     sort(dv + 1, dv + sz + 1);     for (long long i = 1; i <= n; i++) {       cin >> l >> r;       cout << bs(l, r) << endl;     }     return 0;   }   