#include #include int main() { int n, q; std::cin >> n >> q; const int INF = 2'000'000'000; std::vector cost(n, INF); for (int i = 0; i < q; i++) { int type, x; std::cin >> type >> x; x--; if(type == 1) { int ans = x; for(int j = 0; j < n; j++) { ans = std::min(ans, cost[j] + abs(x - j)); } std::cout << ans << "\n"; } else { int c; std::cin >> c; cost[x] = std::min(cost[x], c); } } }