int main(int argc, char const* argv[])
{
int t;
while(scanf("%d",&t) != EOF){
while(t--){
unsigned long long x,k;
scanf("%llu %llu",&x,&k);
int a = floor((double)x/k);
int b = ceil((double)x/k);
unsigned long long p;
unsigned long long q;
bool ans = false;
for(p = 0;!ans;p++){
for(q = 0;!ans;q++){
unsigned long long y = p*a+q*b;
if(y== x) {
printf("%llu %llu\n",p,q);
ans = true;
break;
}
if(y>x){
break;
}
}
}
}
}
return 0;
}