#include //#include using namespace std; //using namespace atcoder; #define all(v) v.begin(),v.end() using ll = long long; using ull = unsigned long long; using lll = __int128; using vll=vector; using vvll = vector>; using P = pair; using vp=vector>; //using mint=modint1000000007; //using mint=modint998244353; const ll INF=1ll<<60; ll mod10=1e9+7; ll mod99=998244353; const double PI = acos(-1); #define rep(i,n) for (ll i=0;i=0;--i) #define rep2(i,a,n) for (ll i=a;i=n;--i) templatebool chmax(T &a, const T &b) { if (abool chmin(T &a, const T &b) { if (b struct segtree{ using T = typename monoid::Type; ll N; vector node; segtree(ll n){ N=1; while(N(N*2-1,monoid::id()); } T operator [](int k){ return node[N-1+k]; } void update(int k,T x){ k+=N-1; node[k]=x; while(k){ k=(k-1)/2; node[k]=monoid::op(node[2*k+1],node[2*k+2]); } } T query(int a,int b,int k,int l,int r){ if(r<=a||b<=l) return monoid::id(); else if(a<=l&&r<=b) return node[k]; else{ int m=(l+r)/2; return monoid::op(query(a,b,2*k+1,l,m),query(a,b,2*k+2,m,r)); } } T sub(int a,int b){ return query(a,b,0,0,N); } }; struct monoid{ using Type = long long; static Type op(Type a,Type b){ return min(a,b); } static Type id(){return INF;} }; bool solve(){ ll N,Q;cin>>N>>Q; segtree segl(N),segr(N); rep(_,Q){ ll t;cin>>t; if(t==1){ ll x;cin>>x; x--; ll ans=x; chmin(ans,min(segl.sub(0,x)+x,segr.sub(x,N)-x)); cout<>x>>c;x--; segl.update(x,min(segl[x],c-x)); segr.update(x,min(segr[x],c+x)); } } return 0; } int main(){ cin.tie(0); ios::sync_with_stdio(false); ll T=1;//cin>>T; rep(i,T) solve(); }