import java.io.*;
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner();
        int n = sc.nextInt();
        Place rightup = new Place();
        Place leftup = new Place();
        Place rightdown = new Place();
        Place leftdown = new Place();
        StringBuilder sb = new StringBuilder();
        for (int i = 0; i < n; i++) {
            long ans = 0;
            int x1 = sc.nextInt();
            int y1 = sc.nextInt();
            int x2 = sc.nextInt();
            int y2 = sc.nextInt();
            ans += rightup.add(-x1, -y1);
            ans += leftup.add(x2, -y1);
            ans += rightdown.add(-x1, y2);
            ans += leftdown.add(x2, y2);
            sb.append(ans).append("\n");
        }
        System.out.print(sb);
    }
    
    
    static class Place {
        TreeMap<Integer, Integer> map = new TreeMap<>();
        
        public Place() {
            map.put(0, 0);
            map.put(Integer.MAX_VALUE, 0);
        }
        
        public long add(int x, int y) {
            long ans = 0;
            Integer key = map.firstKey();
            int prev = key;
            int pValue = map.get(key);
            boolean isSet = false;
            while ((key = map.higherKey(key)) != null) {
                int value = map.get(key);
                if (!isSet && pValue < x) {
                    isSet = true;
                    map.put(prev, x);
                }
                if (key >= y) {
                    if (isSet) {
                        ans += (long)(y - prev) * (x - pValue);
                        if (key > y) {
                            map.put(y, pValue);
                        }
                    }
                    break;
                } else {
                    if (isSet) {
                        ans += (long)(key - prev) * (x - pValue);
                    }
                }
                if (isSet && map.get(prev) < x) {
                    map.remove(prev);
                }
                prev = key;
                pValue = value;
            }
            return ans;
        }
    }
}
class Scanner {
    BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
    StringTokenizer st = new StringTokenizer("");
    
    public Scanner() throws Exception {
        
    }
    
    public int nextInt() throws Exception {
        return Integer.parseInt(next());
    }
    
    public long nextLong() throws Exception {
        return Long.parseLong(next());
    }
    
    public String next() throws Exception {
        if (!st.hasMoreTokens()) {
            st = new StringTokenizer(br.readLine());
        }
        return st.nextToken();
    }
}