#include #include using namespace std; using ll = long long; using namespace atcoder; ll n,q,t,x,c; ll op(ll a, ll b){ return min(a,b); } ll e(){ return LLONG_MAX; } int main(){ cin >> n >> q; segtree left(n),right(n); while(q--){ cin >> t; if(t == 1){ cin >> x; cout << min(x - 1,max(left.prod(0,x) + x,right.prod(x,n) - x)) << endl; } else{ cin >> x >> c; left.set(x - 1,c - x); right.set(x - 1,c + x); } } }