#include using namespace std; using ll = long long; const ll INF = 1LL << 60; int main() { int N, Q; cin >> N >> Q; vector dist(N + 1); for (int i = 1; i <= N; ++i) dist[i] = i - 1; // 初期状態:1歩ずつ歩く while (Q--) { int type; cin >> type; if (type == 1) { int x; cin >> x; cout << dist[x] << endl; } else { int x; ll c; cin >> x >> c; // テレポーター設置 if (dist[x] > c) { dist[x] = c; // 1回の伝播でよい for (int i = x - 1; i >= 1; --i) { if (dist[i] > dist[i + 1] + 1) dist[i] = dist[i + 1] + 1; else break; } for (int i = x + 1; i <= N; ++i) { if (dist[i] > dist[i - 1] + 1) dist[i] = dist[i - 1] + 1; else break; } } } } }