Help me in solving SMOL problem . It shows time limit exceded

My issue

My code

#include <iostream>
using namespace std;

int main() {
	// your code goes here
	long long int t;
	cin>>t;
	while(t--){
	    long long int n,k;
	    
	    cin>>n>>k;
	    long long int m=0;
	    if(n>=k){
	    while(n>0){
	       n=n-k;
	        if(n>=0){
	             m=n;
	        }
	    }
	    }
	    else{
	        m=n;
	    }
	    cout<<m<<endl;
	}
	return 0;
}

Problem Link: CodeChef: Practical coding for everyone