// #include // Temp fix for gcc13 global pragma // #pragma GCC target("avx2,bmi2,popcnt,lzcnt") // #pragma GCC optimize("O3,unroll-loops") #include // #include using namespace std; using namespace numbers; #ifdef LOCAL #include "Debug.h" #else #define debug_endl() 42 #define debug(...) 42 #define debug2(...) 42 #define debug_bin(...) 42 #endif // Returns the largest integer k with x >= k * y template U floor_div(T x, U y){ assert(y > 0); return x / y - (x % y < 0); } // Returns the smallest integer k with x <= k * y template U ceil_div(T x, U y){ assert(y > 0); return x / y + (x % y > 0); } template T &ctmin(T &x){ return x; } template T &ctmin(T &x, const Head &h, const Tail &... t){ return ctmin(x = min(x, h), t...); } template T &ctmax(T &x){ return x; } template T &ctmax(T &x, const Head &h, const Tail &... t){ return ctmax(x = max(x, h), t...); } // std::chunk_by cuz AtCoder is stuck on 3 years old gcc vector> chunk_by(auto data, auto eq){ vector> chunks; for(auto l = data.begin(); l != data.end(); ){ auto r = next(l); vector chunk{*l}; while(r != data.end() && eq(*prev(r), *r)){ chunk.push_back(*r); r = next(r); } chunks.push_back(chunk); l = r; } return chunks; } int main(){ cin.tie(0)->sync_with_stdio(0); cin.exceptions(ios::badbit | ios::failbit); auto solve_testcase = [&](auto testcase_id)->int{ array, 3> a; for(auto j = 0; j < 2; ++ j){ for(auto i = 0; i < 3; ++ i){ cin >> a[i][j]; } } ranges::sort(a); cout << min({ 1LL * a[1][1] * (a[1][0] - a[0][0]) + 1LL * a[2][1] * (a[2][0] - a[0][0]), 1LL * a[0][1] * (a[1][0] - a[0][0]) + 1LL * a[2][1] * (a[2][0] - a[1][0]), 1LL * a[0][1] * (a[2][0] - a[0][0]) + 1LL * a[1][1] * (a[2][0] - a[1][0]) }) << "\n"; return 0; }; int testcase_count; cin >> testcase_count; for(auto testcase_id = 0; testcase_id < testcase_count; ++ testcase_id){ solve_testcase(testcase_id); } return 0; } /* */