#include <bits/stdc++.h>

#define error(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args); }
#define sz(x) (int)x.size()
#define all(x) x.begin(),x.end()

using namespace std;

using ll = long long;

void err(istream_iterator<string> it) {cerr << endl;}
template<typename T, typename... Args>void err(istream_iterator<string> it, T a, Args... args) {cerr << *it << " = " << a << endl;err(++it, args...);}

const int dx[] = {0, -1, 1,  0, 1, -1,  1, -1};
const int dy[] = {1 , 0, 0, -1, 1, -1, -1,  1};

const int mod = 1e9 + 7;
const int N = 1e5 + 5;



int main() {


  ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
  int q;
  cin >> q;
  while(q--){
	  	  ll a , b;
	  	  cin >> a >> b;
	  	  ll ans = abs(a-b);

	  	  if(a == b){
	  		  cout << 0 << ' ' << 0 << '\n';
	  		  continue;
	  	  }
	  	  ll c = (a / ans);
	  	  ll d = ((a + ans - 1) / ans);
	  	  if(d * ans - a <= a - c * ans){
	  		  cout << ans << ' ' << (d * ans - a) << '\n';
	  	  }else{
	  		  cout << ans << ' ' << (a - c * ans) << '\n';
	  	  }

  }








  return 0;
}
