#pragma GCC optimize("Ofast") #pragma GCC optimize("unroll-loops") #include #include #include #include #include #include #include #include #include #include #include #include #include using namespace std; #define rep(i,n,c) for (int i=0;i using vec = vector; template using vvec = vec>; template using vvvec = vec>; using ll = long long; using pii = pair; using pll = pair; using piil = tuple; template inline bool chmin(T &a, T b){ if (a>b){ a = b; return true; } return false; } template inline bool chmax(T &a, T b){ if (a T sum(vec x){ T res=0; for (auto e:x){ res += e; } return res; } template void printv(vec x){ for (auto e:x){ cout<>n>>q; vector triangle(n); for (int i=0;i>a>>b>>c>>d>>e>>f; triangle[i] = {area(a,b,c,d,e,f),min({a,c,e}),max({a,c,e})}; } sort(all(triangle)); triangle.resize(n+q); int next_idx=n; int t; int l,r; ll ans=-1; for (int i=0;i>t; if (t==1){ cin>>a>>b>>c>>d>>e>>f; triangle[next_idx] = {area(a,b,c,d,e,f),min({a,c,e}),max({a,c,e})}; next_idx += 1; } else{ cin>>l>>r; ans=-1; for (int j=next_idx-1;j>n-1;j--){ if (l<=get<1>(triangle[j]) and get<2>(triangle[j])<=r){ chmax(ans,get<0>(triangle[j])); } } for (int j=n-1;j>-1;j--){ if (l<=get<1>(triangle[j]) and get<2>(triangle[j])<=r){ chmax(ans,get<0>(triangle[j])); break; } } cout<