Help me in solving FLOW016 problem

My issue

what is the meaning of Time Limit Exceeded and how can i fix it

My code

# cook your dish here
m=int(input())
smallest=9999999
greatest=0
for i in range(m):
    a,b=map(int,input().split())
    
    if a<smallest:
        smallest=a 
    else:
        smallest=b 
    
    for j in range(1,smallest+1):
        if a%j==0 and b%j==0:
            greatest=j 
    result=(a*b)//greatest 
    print(greatest, result)

Learning course: Basic Math using Python
Problem Link: Practice Problem in - CodeChef

@chatlamohan2
TLE means time limit exceed .
it means your code’s time complexity is very high and u need to optimize your solution more to get it accepted.