//#pragma comment(linker, "/STACK:16777216")
#include<iostream>
#include<cstdio>
//#include<cmath>
//#include<algorithm>
#include<vector> 
#include<cstring>
#include<string>
//#include<queue>
#define mp make_pair
#define scn second
#define frs first
#define pb push_back
#define NAME "rod"
#define fop freopen(NAME ".in", "r", stdin); freopen(NAME ".out", "w", stdout); 
using namespace std;
const unsigned long long P=239017, MaxN=2100000, INF=100000000;
typedef unsigned long long ull;
typedef long long ll;
typedef pair<int, int> pi;

int l[10010], d[10110];
int n;

int main(){
	fop;
	scanf("%d", &n);
	for (int i = 0; i < n; ++i)
		scanf("%d%d", &l[i], &d[i]);
	int mx = 0;
	for (int i = 0; i < n; ++i)
		mx = max(mx, max(d[i], l[i] - d[i]));
	
	for (int i = 0; i < n; ++i) {
		if (2 * d[i] > l[i]) 
			printf("%d %d\n", mx - d[i] + 1, mx - d[i] + 1 + (2 * d[i] - l[i]));					
		else {
			d[i] = l[i] - d[i];
			printf("%d %d\n", mx - d[i] + 1 + (2 * d[i] - l[i]), mx - d[i] + 1);		
		}
	}

	return 0;
}