#include<bits/stdc++.h>
using namespace std;
const int N=205;
const int DS=900;
int n,tot,ran[10];
int x[N],y[N],r[N],a[N],b[N],c[N],d[N],s[N],que[N];
unsigned int Se;
set<pair<int,int> > S;
set<pair<int,int> > :: iterator it;
pair<int,int> aa[N];
bool U(int i){
	a[i]--; bool flag=0;
	for (int j=1; j<=n; j++){
		if (i==j) continue;
		if (max(a[i],a[j])<min(c[i],c[j]) && max(b[i],b[j])<min(d[i],d[j])){ flag=1; break; }
	}
	if (!flag){
		S.erase(make_pair(r[i]-s[i],i));
		s[i]+=d[i]-b[i];
		if (s[i]>=r[i]+DS) que[i]=-1,tot--;
		else S.insert(make_pair(r[i]-s[i],i));
		return 1;
	}
	a[i]++;
	return 0;
}
bool D(int i){
	c[i]++; bool flag=0;
	for (int j=1; j<=n; j++){
		if (i==j) continue;
		if (max(a[i],a[j])<min(c[i],c[j]) && max(b[i],b[j])<min(d[i],d[j])){ flag=1; break; }
	}
	if (!flag){
		S.erase(make_pair(r[i]-s[i],i));
		s[i]+=d[i]-b[i];
		if (s[i]>=r[i]+DS) que[i]=-1,tot--;
		else S.insert(make_pair(r[i]-s[i],i));
		return 1;
	}
	c[i]--;
	return 0;
}
bool L(int i){
	b[i]--; bool flag=0;
	for (int j=1; j<=n; j++){
		if (i==j) continue;
		if (max(a[i],a[j])<min(c[i],c[j]) && max(b[i],b[j])<min(d[i],d[j])){ flag=1; break; }
	}
	if (!flag){
		S.erase(make_pair(r[i]-s[i],i));
		s[i]+=c[i]-a[i];
		if (s[i]>=r[i]+DS) que[i]=-1,tot--;
		else S.insert(make_pair(r[i]-s[i],i));
		return 1;
	}
	b[i]++;
	return 0;
}
bool R(int i){
	d[i]++; bool flag=0;
	for (int j=1; j<=n; j++){
		if (i==j) continue;
		if (max(a[i],a[j])<min(c[i],c[j]) && max(b[i],b[j])<min(d[i],d[j])){ flag=1; break; }
	}
	if (!flag){
		S.erase(make_pair(r[i]-s[i],i));
		s[i]+=c[i]-a[i];
		if (s[i]>=r[i]+DS) que[i]=-1,tot--;
		else S.insert(make_pair(r[i]-s[i],i));
		return 1;
	}
	d[i]--;
	return 0;
}
int main(){
//	freopen("a.out","w",stdout);
	scanf("%d",&n); tot=n;
	srand(303837088);
	for (int i=1; i<=n; i++){
		scanf("%d%d%d",&x[i],&y[i],&r[i]);
		a[i]=x[i],b[i]=y[i],c[i]=x[i]+1,d[i]=y[i]+1; s[i]=1;
		S.insert(make_pair(r[i]-s[i],i));
		aa[i]=make_pair(r[i]-s[i],i);
	}
	sort(aa+1,aa+1+n);
	ran[1]=1,ran[2]=2,ran[3]=3,ran[4]=4;
	for (int i=1; i<=50; i++)
		for (int J=n; J<=n-20; J++){
			int x=aa[J].second;
			if (que[x]==-1) continue;
			random_shuffle(ran+1,ran+5);
			for (int j=1; j<=4; j++){
				if (ran[j]==1 && a[x]>0 && U(x)) break;
				if (ran[j]==2 && c[x]<10000 && D(x)) break;
				if (ran[j]==3 && b[x]>0 && L(x)) break;
				if (ran[j]==4 && d[x]<10000 && R(x)) break;
			}
		}
	for (int i=1; i<=300000; i++){
		if (!tot) break; int x;
		if (rand()%4==1 && !S.empty()){
			it=S.end(); it--;
			x=(*it).second;
		} else {
			x=rand()%n+1;
			while (que[x]==-1) x=rand()%n+1;
		}
		random_shuffle(ran+1,ran+5);
		for (int j=1; j<=4; j++){
			if (ran[j]==1 && a[x]>0 && U(x)) break;
			if (ran[j]==2 && c[x]<10000 && D(x)) break;
			if (ran[j]==3 && b[x]>0 && L(x)) break;
			if (ran[j]==4 && d[x]<10000 && R(x)) break;
		}
	}
	for (int i=1; i<=n; i++) printf("%d %d %d %d\n",a[i],b[i],c[i],d[i]);
	return 0;
}
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,sse4.1,sse4.2,popcnt,mmx,avx")
#include <bits/stdc++.h>
using namespace std;

typedef long long ll;
typedef long double ld;
#define PB push_back
#define MP make_pair
#define endl "\n"
#define fst first
#define snd second
const int UNDEF = -1;
const int INF=1<<30;
template<typename T> inline bool chkmax(T &aa, T bb) { return aa < bb ? aa = bb, true : false; }
template<typename T> inline bool chkmin(T &aa, T bb) { return aa > bb ? aa = bb, true : false; }
typedef pair<ll,ll> pll;typedef vector<ll> vll;typedef pair<int,int> pii;typedef vector<int> vi;typedef vector<vi> vvi;typedef vector<pii> vpii;typedef vector<pll> vpll;
template<typename T> void makeunique(vector<T> &vx) {sort(vx.begin(),vx.end());auto it=unique(vx.begin(),vx.end());vx.resize(std::distance(vx.begin(),it));}

void solve(long long n, std::vector<long long> A, std::vector<long long> B){
	ll sumA=0;
	for (auto &w:A) sumA+=w;
	vll C[2];
	for (int i=0;i<n;i++) {
		C[i%2].PB(B[i]-A[i]);
	}
	for (int k=0;k<2;k++) sort(C[k].begin(),C[k].end(),greater<ll>());
	ll ans=0;
	for (int i=0;i<C[0].size();i++) {
		ll now=C[0][i]+C[1][i];
		if (now>0) ans+=now;
	}
	ll final=ans+sumA;
	printf("%lld\n",final);
}

// Generated by 1.1.7.1 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
int main(){
    long long N;
    scanf("%lld",&N);
    std::vector<long long> A(N);
    for(int i = 0 ; i < N ; i++){
        scanf("%lld",&A[i]);
    }
    std::vector<long long> B(N);
    for(int i = 0 ; i < N ; i++){
        scanf("%lld",&B[i]);
    }
    solve(N, std::move(A), std::move(B));
    return 0;
}
