Problem Code: PRODUCT (The Product Mystery)What is wrong in these code ERROR TLE

#include<iostream>
using namespace std;
int main()
{
    int t;
    cin>>t;
    while(t--)
    {
    long long int b,c;
    cin>>b>>c;
    for(long long int a=1;a<=c;a++)
    {
        if((a*b)%c==0)
        {
            cout<<a<<endl;
            break;
        }
    }
    }
}

Approach –
hint 1 - for 7,8 answer is 8.
for 8,2 answer is 1.
for 8,12 answer is 3.
hint 2 - see that what are we calculating at first what relation can you bind of a with c.
hint 3 - just imply how can you find a from b.

Solution –
You can write a cancerous binary search function or do it by (__gcd) function which finds out the greatest common divisor of two numbers.
So, ans = c/(__gcd(b,c));
like sample input 8,12 the gcd is 4 then the answer will be 12/4 = 3.