#include #include using namespace std; using ll = long long; using namespace atcoder; ll op(ll a, ll b) { return min(a, b); } const ll INF = 1LL << 60; ll e() { return INF; } ll n,q,t,x,c; int main(){ cin >> n >> q; vector init(n, INF); atcoder::segtree left(init), right(init); while(q--){ cin >> t; if(t == 1){ cin >> x; ll ans = x - 1; cout << min(x - 1,min(left.prod(0,x) + x,right.prod(x - 1,n) - x)) << "\n"; } else if(t == 2){ cin >> x >> c; left.set(x-1, c - x); right.set(x-1, c + x); } } }