#include<bits/stdc++.h>
#include <queue>
using namespace std;
struct Student{
    int yuwen,shuxue,waiyu;
    Student(int a,int b,int c){
        yuwen=a;shuxue=b;waiyu=c;
    }
    bool operator<(const Student& other)const{
        if ((this->yuwen+this->shuxue+this->waiyu)!=(other.yuwen+other.shuxue+other.waiyu)) {
            return (this->yuwen+this->shuxue+this->waiyu)<(other.yuwen+other.shuxue+other.waiyu);
        }else if (this->yuwen!=other.yuwen) {
            return this->yuwen<other.yuwen;
        }else if (this->shuxue!=other.shuxue) {
            return this->shuxue<other.shuxue;
        }else {
            return this->waiyu<other.waiyu;
        }
    }
};
int main(){
    int n{0},op{0},x{0},y{0},z{0};priority_queue<Student>pq;
    cin>>n;
    for (int i=0; i<n;++i) {
        cin>>op;
        if (op==1) {
            cin>>x>>y>>z;
            Student s(x,y,z);
            pq.push(s);
        }else if (op==2) {
            cout<<pq.top().yuwen<<' '<<pq.top().shuxue<<' '<<pq.top().waiyu<<endl;
        }else if (op==3) {
            pq.pop();
        }else {
            cout<<"程序错误1"<<endl;
        }
    }
    return 0;
}