#include <iostream>
#include <cmath>
using namespace std;
typedef unsigned long long ll ;
int main()
{
int t;
cin >> t;
while(t--)
{
ll x, y;
cin >> x >> y;
if(x * 3 >= y)
{
cout << 0 << " ";
}
else
{
cout << y - 3 * x << " ";
}
ll maxn = 4 * x;
cout << x - (ceil)(1.0 * (maxn - y) / 2) << endl;
}
return 0 ;
}