#include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #define popcount __builtin_popcount using namespace std; using namespace atcoder; typedef long long ll; typedef pair P; template struct SegmentTree{ using F=function; int sz; vector seg; const F f; const Monoid e; SegmentTree(int n, const F f, const Monoid &e): f(f), e(e){ sz=1; while(sz v): f(f), e(e){ sz=1; while(sz=1; i--){ seg[i]=f(seg[2*i], seg[2*i+1]); } } void update(int k, const Monoid &x){ k+=sz; seg[k]=x; while(k>1){ k>>=1; seg[k]=f(seg[2*k], seg[2*k+1]); } } Monoid query(int a, int b){ a+=sz, b+=sz; Monoid ret=e; for(;a>=1, b>>=1){ if(b&1) ret=f(ret, seg[--b]); if(a&1) ret=f(ret, seg[a++]); } return ret; } /*Monoid query(int a, int b){ //演算が非可換のとき a+=sz, b+=sz; Monoid retl=e, retr=e; for(;a>=1, b>>=1){ if(b&1) retr=f(seg[--b], retr); if(a&1) retl=f(retl, seg[a++]); } return f(retl, retr); }*/ Monoid operator[](const int &k) const{ return seg[k+sz]; } }; int main() { ll n; int m; cin>>n>>m; using Pl=pair; vector a(m); for(int i=0; i>a[i].first; a[i].second=i+1; } SegmentTree seg(m, [](Pl p, Pl q){ return max(p, q);}, Pl(-1, -1), a); int q; cin>>q; while(q--){ int t; int x; ll y; cin>>t>>x>>y; x--; if(t==1){ a[x].first+=y; seg.update(x, a[x]); }else if(t==2){ a[x].first-=y; seg.update(x, a[x]); }else{ cout<