#include"bits/stdc++.h" using namespace std; using ll=long long; templateinline T in(istream&is=cin){return*istream_iterator(is);} templateclass Container=vector,templateclass Allocator=allocator>inline Container>ins(istream&is=cin){return{istream_iterator(is),istream_iterator()};} templateconcept pushbackable=requires(Container&c){c.push_back(declval());}; templateconcept reservable=requires(Container&c){c.reserve();}; templateclass Container=vector,templateclass Allocator=allocator>requires pushbackable>>inline Container>ins(size_t n,istream&is=cin){Container>c;if constexpr(reservable)c.reserve(n);copy_n(istream_iterator(is),n,back_inserter(c));return c;} templateinline bool chmin(T&a,T b){return a>b?a=b,true:false;} templateinline bool chmax(T&a,T b){return ainline auto multdim_vector_v(T v,size_t size,Sizes...sizes){if constexpr(sizeof...(Sizes)==0)return vector(size,v);else return vector(size,multdim_vector_v(v,sizes...));} templateinline auto multdim_vector(Sizes...sizes){return multdim_vector_v(T{},sizes...);} template class cyclic_imos final : private std::vector> { friend cyclic_imos; public: using coordinate = std::array; struct segment { coordinate begin, end; }; constexpr inline static std::size_t dimension = Dimension; using std::vector>::begin; using std::vector>::end; using std::vector>::operator[]; private: using std::vector>::size; T& get(const std::span idxs) { return (*this)[idxs.front()].get(idxs.template last()); } void set( const std::span begin, const std::span end, const T weight ) { (*this)[begin.front()].set( begin.template last(), end.template last(), weight ); (*this)[end.front()].set( begin.template last(), end.template last(), -weight ); } cyclic_imos &operator+=(const cyclic_imos &ci) { for (std::size_t i = 0; i < size(); ++i) { (*this)[i] += ci[i]; } return *this; } public: template cyclic_imos(const std::size_t size, const Sizes... sizes) : std::vector>( size + 1, cyclic_imos(sizes...) ) { } T& get(const coordinate &c) { return get(std::span{c}); } void set(const segment &s, const T weight) { set(std::span{s.begin}, std::span{s.end}, weight); } void set_cyclic(const segment &s, const T weight) { set(s, weight); for (unsigned i = 1; i < (1 << Dimension); ++i) { segment correction; for (unsigned j = 0; j < Dimension; ++j) { if (i & (1 << j)) { if (s.begin[j] <= s.end[j]) { goto CONTINUE; } correction.begin[j] = 0; correction.end[j] = size() - 1; } else { correction.begin[j] = s.begin[j]; correction.end[j] = s.end[j]; } } set(correction, weight); CONTINUE: ; } } void accumulate() { for (std::size_t i = 0; i < size() - 1; ++i) { (*this)[i + 1] += (*this)[i]; } for (auto &child : *this) { child.accumulate(); } } }; template class cyclic_imos final : private std::vector { friend cyclic_imos; public: using coordinate = std::array; struct segment { coordinate begin, end; }; constexpr inline static std::size_t dimension = 1; using std::vector::begin; using std::vector::end; using std::vector::operator[]; private: using std::vector::size; T& get(const std::span idxs) { return (*this)[idxs.front()]; } void set( const std::span begin, const std::span end, const T weight ) { (*this)[begin.front()] += weight; (*this)[end.front()] -= weight; } cyclic_imos &operator+=(const cyclic_imos &ci) { for (std::size_t i = 0; i < size(); ++i) { (*this)[i] += ci[i]; } return *this; } public: cyclic_imos(const std::size_t size) : std::vector(size + 1) { } T& get(const coordinate &c) { return (*this)[c.front()]; } T& get(const std::size_t idx) { return (*this)[idx]; } void set(const segment &s, const T weight) { set(std::span{s.begin}, std::span{s.end}, weight); } void set(const size_t begin, const size_t end, const T weight) { set({.begin = begin, .end = end}, weight); } void set_cyclic(const segment &s, const T weight) { set(s, weight); if (s.begin.front() > s.end.front()) { (*this).front() += weight; (*this).back() -= weight; } } void set_cyclic(const std::size_t begin, const std::size_t end, const T weight) { set_cyclic({.begin = begin, .end = end}, weight); } void accumulate() { for (std::size_t i = 0; i < size() - 1; ++i) { (*this)[i + 1] += (*this)[i]; } } }; template auto make_cyclic_imos(auto... sizes) { return cyclic_imos(sizes...); } int main() { struct enemy{ ll x,y,hp; }; ll n=in(),k=in(); vectorenemies(n); for(ll i=0;i(1000,1000); for(ll i=0;i