#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
using namespace std;
typedef long long int ll;
typedef pair<int,int> P;
#define yn {puts("YES");}else{puts("NO");}
#define MAX_N 200005

int main() {
    int dp[4][20001];
    rep(i,4)rep(j,20001)dp[i][j] = 0;

    int n;
    cin >> n;
    rep(loop, n){
        int a, b, c ,d;
        cin >> a >> b >> c >> d;
        a *= -1; b *= -1;
        int ans = 0;

        drep(i,b+1){
            if(i == 0)break;
            if(dp[0][i] < a){
                ans += a - dp[0][i];
                dp[0][i] = a;
            }
        }

        drep(i,d+1){
            if(i == 0)break;
            if(dp[1][i] < a){
                ans += a - dp[1][i];
                dp[1][i] = a;
            }
        }

        drep(i,b+1){
            if(i == 0)break;
            if(dp[2][i] < c){
                ans += c - dp[2][i];
                dp[2][i] = c;
            }
        }

        drep(i,d+1){
            if(i == 0)break;
            if(dp[3][i] < c){
                ans += c - dp[3][i];
                dp[3][i] = c;
            }
        }

        cout << ans << endl;
    }
}