#include using namespace std; typedef long long ll; typedef long double ld; #define inf 1000000007 #define MP make_pair #define MT make_tuple #define PB push_back #define fi first #define se second #define rep(i,n) for(int i = 0; i < (int)(n); ++i) #define rrep(i,n) for(int i = (int)n-1; i >= 0; --i) #define srep(i,a,b) for(int i = (int)a; i < (int)(b); ++i) #define all(x) (x).begin(),(x).end() #define SUM(v) accumulate(all(v), 0LL) #define MIN(v) *min_element(all(v)) #define MAX(v) *max_element(all(v)) #define lb(c, x) distance((c).begin(), lower_bound(all(c), (x))) #define ub(c, x) distance((c).begin(), upper_bound(all(c), (x))) #define UNIQUE(x) sort(all(x)), x.erase(unique(all(x)), x.end()) #define SZ(c) (int)(c).size() template ostream& operator << (ostream& os, vector& vec) { os << "{"; for (int i = 0; i<(int)vec.size(); i++) { os << vec[i] << (i + 1 == (int)vec.size() ? "" : ", "); } os << "}"; return os; } // pair出力 template ostream& operator << (ostream& os, pair pair_var) { os << "(" << pair_var.first << ", " << pair_var.second << ")"; return os; } // map出力 template ostream& operator << (ostream& os, map& map_var) { os << "{"; for(auto itr = map_var.begin(); itr != map_var.end(); itr++){ os << "(" << itr->first << ", " << itr->second << ")"; itr++; if(itr != map_var.end()) os << ", "; itr--; } os << "}"; return os; } // set 出力 template ostream& operator << (ostream& os, set& set_var) { os << "{"; for(auto itr = set_var.begin(); itr != set_var.end(); itr++){ os << (*itr); ++itr; if(itr != set_var.end()) os << ", "; itr--; } os << "}"; return os; } #define overload2(_1, _2, name, ...) name #define vec(type, name, ...) vector name(__VA_ARGS__) #define VEC(type, name, size) \ vector name(size); \ IN(name) #define vv(type, name, h, ...) vector> name(h, vector(__VA_ARGS__)) #define VV(type, name, h, w) \ vector> name(h, vector(w)); \ IN(name) #define vvv(type, name, h, w, ...) vector>> name(h, vector>(w, vector(__VA_ARGS__))) #define vvvv(type, name, a, b, c, ...) \ vector>>> name(a, vector>>(b, vector>(c, vector(__VA_ARGS__)))) #define INT(...) \ int __VA_ARGS__; \ IN(__VA_ARGS__) #define LL(...) \ ll __VA_ARGS__; \ IN(__VA_ARGS__) #define STR(...) \ string __VA_ARGS__; \ IN(__VA_ARGS__) #define CHR(...) \ char __VA_ARGS__; \ IN(__VA_ARGS__) #define DBL(...) \ double __VA_ARGS__; \ IN(__VA_ARGS__) int scan() { return getchar(); } void scan(int &a) { cin >> a; } void scan(long long &a) { cin >> a; } void scan(char &a) { cin >> a; } void scan(double &a) { cin >> a; } void scan(string &a) { cin >> a; } template void scan(pair &p) { scan(p.first), scan(p.second); } template void scan(vector &); template void scan(vector &a) { for(auto &i : a) scan(i); } template void scan(T &a) { cin >> a; } void IN() {} template void IN(Head &head, Tail &...tail) { scan(head); IN(tail...); } const string YESNO[2] = {"NO", "YES"}; const string YesNo[2] = {"No", "Yes"}; const string yesno[2] = {"no", "yes"}; void YES(bool t = 1) { cout << YESNO[t] << endl; } void NO(bool t = 1) { YES(!t); } void Yes(bool t = 1) { cout << YesNo[t] << endl; } void No(bool t = 1) { Yes(!t); } void yes(bool t = 1) { cout << yesno[t] << endl; } void no(bool t = 1) { yes(!t); } #ifdef LOCAL void debug_out() { cerr << endl; } template void debug_out(Head H, Tail... T) { cerr << " " << H; debug_out(T...); } #define dbg(...) \ cerr << __LINE__ << " [" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__) #define dump(x) cerr << __LINE__ << " " << #x << " = " << (x) << endl #else #define dbg(...) (void(0)) #define dump(x) (void(0)) #endif template void Fill(A (&array)[N], const T &val){ std::fill( (T*)array, (T*)(array+N), val ); } template T ceil(T x, T y) {assert(y >= 1);return (x > 0 ? (x + y - 1) / y : x / y);} template T floor(T x, T y) {assert(y >= 1);return (x > 0 ? x / y : (x + y - 1) / y);} vector iota(int n) {vector a(n);iota(all(a), 0);return a;} template T POW(T x, int n) {T res = 1;for(; n; n >>= 1, x *= x){if(n & 1) res *= x;}return res;} ll pow2(int i) { return 1LL << i; } int topbit(signed t) { return t == 0 ? -1 : 31 - __builtin_clz(t); } int topbit(ll t) { return t == 0 ? -1 : 63 - __builtin_clzll(t); } int lowbit(signed a) { return a == 0 ? 32 : __builtin_ctz(a); } int lowbit(ll a) { return a == 0 ? 64 : __builtin_ctzll(a); } // int allbit(int n) { return (1 << n) - 1; } ll allbit(ll n) { return (1LL << n) - 1; } int popcount(signed t) { return __builtin_popcount(t); } int popcount(ll t) { return __builtin_popcountll(t); } bool ispow2(int i) { return i && (i & -i) == i; } template void fold_in(vector &v) {} template void fold_in(vector &v, Head &&a, Tail &&...tail) { for(auto e : a) v.emplace_back(e); fold_in(v, tail...); } template void renumber(vector &v) {} template void renumber(vector &v, Head &&a, Tail &&...tail) { for(auto &&e : a) e = lb(v, e); renumber(v, tail...); } template void zip(vector &head, Args &&...args) { vector v; fold_in(v, head, args...); sort(all(v)), v.erase(unique(all(v)), v.end()); renumber(v, head, args...); } template inline bool chmax(T &a, T b){ if(a inline bool chmin(T &a, T b){ if(a>b){ a = b; return true; } return false; } template class segtree { private: int n, sz; vector node; public: void init(const vector& v){ sz = (int)v.size(); n = 1; while(n < sz){ n *= 2; } node.assign(2*n, numeric_limits::min()); for(int i = 0; i < sz; i++){ node[i+n] = v[i]; } for(int i=n-1; i>=1; i--){ node[i] = max(node[2*i], node[2*i+1]); } } void update(int k, const T a) { node[k+=n] = a; while(k>>=1){ node[k] = max(node[2*k], node[2*k+1]); } } T query(int a, int b) { T res1 = numeric_limits::min(), res2 = numeric_limits::min(); a += n, b += n; while(a != b){ if(a % 2) res1 = max(res1, node[a++]); if(b % 2) res2 = max(res2, node[--b]); a >>= 1, b >>= 1; } return max(res1, res2); } void print(){ for(int i = 0; i < sz; i++){ cout << query(i, i+1) << " "; } cout << endl; } }; //座標の型, 値の型 template class RangeTree { public: static_assert(std::is_integral::value, "Integral required."); private: using CT = CandidateType; using VT = ValueType; using pcc = pair; using pci = pair; int n, sz; vector > seg; // y座標, x座標 vector > yx; // y座標, x座標 vector sorted; void update_(int id, const CT x, const CT y, const VT val) { id += n-1; const int yid = lower_bound(all(yx[id]), pcc(y, x)) - yx[id].begin(); seg[id].update(yid, val); while(id > 0){ id = (id - 1) / 2; const int yid = lower_bound(all(yx[id]), pcc(y, x)) - yx[id].begin(); seg[id].update(yid, val); } } VT query(const int lxid, const int rxid, const CT ly, const CT ry, const int k, const int l, const int r) { if(r <= lxid || rxid <= l) return numeric_limits::min(); if(lxid <= l && r <= rxid){ const int lyid = lower_bound(all(yx[k]), pcc(ly, numeric_limits::min())) - yx[k].begin(); const int ryid = upper_bound(all(yx[k]), pcc(ry, numeric_limits::min())) - yx[k].begin(); return (lyid >= ryid) ? numeric_limits::min() : seg[k].query(lyid, ryid); }else{ return max(query(lxid, rxid, ly, ry, 2*k+1, l, (l+r)/2), query(lxid, rxid, ly, ry, 2*k+2, (l+r)/2, r)); } } public: // 座標, 点の値 RangeTree(const vector& cand, const vector& val) : n(1), sz((int)cand.size()), sorted(sz){ while(n < sz) n *= 2; for(int i = 0; i < sz; ++i){ sorted[i] = {cand[i].first, i}; } sort(all(sorted), [&](const pcc& a, const pcc& b){ return (a.first == b.first) ? (cand[a.second].second < cand[b.second].second) : (a.first < b.first); }); yx.resize(2*n-1), seg.resize(2*n-1); for(int i = 0; i < sz; ++i){ yx[i+n-1] = {{sorted[i].second, sorted[i].first}}; vector arg = {val[sorted[i].second]}; seg[i+n-1].init(arg); sorted[i].second = cand[sorted[i].second].second; } for(int i = n-2; i >= 0; --i){ yx[i].resize((int)yx[2*i+1].size() + (int)yx[2*i+2].size()); if(yx[i].empty()) continue; merge(all(yx[2*i+1]), all(yx[2*i+2]), yx[i].begin(), [&](const pcc& a, const pcc& b){ return (cand[a.first].second == cand[b.first].second) ? (a.second < b.second) : (cand[a.first].second < cand[b.first].second); }); vector arg((int)yx[i].size()); for(int j = 0; j < (int)yx[i].size(); ++j){ arg[j] = val[yx[i][j].first]; } seg[i].init(arg); } for(int i = 0; i < 2*n-1; ++i){ for(pcc& e : yx[i]){ e.first = cand[e.first].second; } } } // 点 (x,y) の更新を行う void update(const CT x, const CT y, const VT val){ const int id = lower_bound(all(sorted), pcc(x, y)) - sorted.begin(); return update_(id, x, y, val); } // [lx,rx) × [ly,ry) の長方形領域のクエリに答える VT query(const CT lx, const CT ly, const CT rx, const CT ry){ const int lxid = lower_bound(all(sorted), pcc(lx, numeric_limits::min())) - sorted.begin(); const int rxid = upper_bound(all(sorted), pcc(rx, numeric_limits::min())) - sorted.begin(); return (lxid >= rxid) ? numeric_limits::min() : query(lxid, rxid, ly, ry, 0, 0, n); } }; int main(){ cin.tie(0); ios::sync_with_stdio(false); INT(n,q); map,ll > mp; set > st; rep(i,n){ LL(a,b,c,d,e,f); ll X = min({a,c,e}); ll Y = max({a,c,e}); ll S = (c-a)*(f-b) - (e-a)*(d-b); S = abs(S); st.insert(MP(X,Y)); chmax(mp[MP(X,Y)],S); } int m = mp.size(); vector > cand; vector val; for(auto x:mp){ cand.push_back(x.first); val.push_back(x.second); } vector,ll> > p; vector,ll> > upd; rep(zz,q){ INT(t); if(t==1){ LL(a,b,c,d,e,f); ll X = min({a,c,e}); ll Y = max({a,c,e}); ll S = (c-a)*(f-b) - (e-a)*(d-b); S = abs(S); if(st.count(MP(X,Y))==0){ cand.push_back(MP(X,Y)); val.push_back(-1); st.insert(MP(X,Y)); } upd.push_back(MP(MP(X,Y),S)); p.push_back(MP(MP(X,Y),upd.size()-1)); }else{ LL(X,Y); p.push_back(MP(MP(X,Y),-1)); } } dbg(cand); dbg(val); RangeTree rt(cand,val); rep(zz,q){ if(p[zz].second==-1){ dbg(p[zz].first); ll ans = rt.query(p[zz].first.first,-inf,inf,p[zz].first.second+1); if(ans<=0){ cout << -1 << "\n"; }else{ cout << ans << "\n"; } }else{ int id = p[zz].second; if(chmax(mp[upd[id].first],upd[id].second)){ rt.update(upd[id].first.first,upd[id].first.second,upd[id].second); } } } return 0; }