#include <bits/stdc++.h>

#define all(v) begin(v), end(v)
#define fi first
#define se second


#define siz(v) (int)(v).size()
#define dbg(x) "[" #x " = " << x << "]"

#define BIT(x, i) (((x) >> (i)) & 1)
#define MASK(i) (1LL << (i))

using namespace std;

const long long inf = 4e18 + 12;
const int infINT = 1e9 + 123, mod = 999876149;

bool M1;

typedef pair<int, int > ii;

void add(int &a, const int &b){
    a += b;
    if (a >= mod) a -= mod;
}

int bin_pow(int a, int k){
    int res = 1;
    while(k){
        if (k & 1) res = 1LL * res * 1LL * a % mod;
        k >>= 1; a = 1LL * a * 1LL * a % mod;
    }
    return res;
}

template<class X, class Y> bool minimize(X &x, const Y &y){return x >= y ? x = y, 1: 0;}
template<class X, class Y> bool maximize(X &x, const Y &y){return x < y ? x = y, 1: 0;}

long long a[3], b[3];

long long solveA(){
    return max({a[0], a[1], a[2]}) * (b[0] + b[1] + b[2]);
}

long long solveB(){
    long long mi = inf;
    for(int i = 0; i < 3; i++){
        long long A = 0, B = 0;
        for(int j = 0; j < 3; j++) if (i != j){
            A = max(A, a[j]); B += b[j];
        }
        A += a[i]; B = max(B, b[i]);
        mi = min(mi, 1LL * A * 1LL * B);
    }
    return mi;
}

void input(){
    for(int i = 0; i < 3; i++) cin >> a[i] >> b[i];
}

void solve(){
    long long res = inf;

    for(int mask = 0; mask < 8; mask++){
        for(int i = 0; i < 3; i++) if (BIT(mask, i)){
            swap(a[i], b[i]);
        }

        res = min(res, solveA());
        res = min(res, solveB());

        for(int i = 0; i < 3; i++) if (BIT(mask, i)){
            swap(a[i], b[i]);
        }
    }

    cout << res << '\n';
}

bool M2;
signed main(){
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    #define task "test"
    if (fopen(task".inp", "r")){
        freopen(task".inp", "r", stdin);
        freopen(task".out", "w", stdout);
    }
    int t = 1;
    cin >> t;
    while(t--){
        input();
        solve();
    }
    cerr << (1.0 * clock()) / CLOCKS_PER_SEC << ".s\n";
    cerr << (&M2 - &M1) / 1048576 << " mb\n";
}