1. 

/**
* Angewandte Mathematik, SS09, IFB 2C
* ACM Problem #10673 Play with Floor and Ceil
*
* @author David Leib
* @author Julius Tschannerl
* @version 1.0, 05/08/2009
*
* Status : Accepted
* Runtime: 0.428
*/
//package Floor;

import java.util.*;

public class Main {


static long p = 0;
static long q = 0;
static long m = 0;
static long n = 0;


public static void main(String[] args) {
Scanner sc = new Scanner(System.in);

int count = sc.nextInt();

while (count-- > 0){
long x = sc.nextLong();
long k = sc.nextLong();
p = 0;
q = 0;
m = x/k;
n = m+1;
if(k == 2)
System.out.printf("%d %d\n", 1 , 1);
else if(m > 0 && x%m == 0)
System.out.printf("%d %d\n", p += (x/m), q);
else if(x%n == 0)
System.out.printf("%d %d\n", p, q += (x/n) );
else
System.out.printf("%d %d\n",-x,x);
}
}
}