#include <bits/stdc++.h>
int mod = 1000000007;
using namespace std;
using namespace std;
int main() {
  ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0);
  ;
  int t;
  int a, b;
  cin >> t;
  while (t--) {
    cin >> a >> b;
    if (a < b) swap(a, b);
    if (b == 0 && a != 0) {
      cout << a << " " << 0 << '\n';
      continue;
    } else if (b == 0 && a == 0) {
      cout << 0 << " " << 0 << '\n';
      continue;
    } else if (a == b) {
      cout << 0 << " " << 0 << '\n';
    } else {
      if (a > 2 * b) {
        int val = a - 2 * b;
        cout << b + val << " " << val << '\n';
      } else if (a < 2 * b) {
        int val = 2 * b - a;
        cout << b - val << " " << val << '\n';
      } else {
        cout << b << " " << 0 << '\n';
      }
    }
  }
}
