#include<bits/stdc++.h>
using namespace std;
const int maxn=1e5+10;
struct dd {
int to,cost;
dd(int xx=0,int yy=0):to(xx),cost(yy) {
}
bool operator >(const dd&aa)const {
return cost>aa.cost;
}
};
priority_queue<dd,vector<dd>,greater<dd> >op;
int main() {
int n,m;
for(int i=1; i<=m; i++) {
int a;
cin>>a;
if(a==3) {
int b,c;
cin>>b>>c;
//b-c>=0
//b-c<=0
g[b].push_back(dd(a,0));
g[a].push_back(dd(b,0));
} else if(a==1) {
int b,c,d;
cin>>b>>c>>d;
//b-c>=d; b>=c+d; b+(-d)>=c c是节点
g[b].push_back(dd(c,-d));
} else {
int b,c,d;
cin>>b>>c>>d;
//b-c<=d; b<=c+d; b是节点
g[d].push_back(dd(b,d));
}
}
return 0;
}