#include using namespace std; #define int long long int INF = 1 << 30; struct Solver { set > st; Solver() { st.emplace(INF, 0); st.emplace(0, INF); } int query(int x, int y) { int res = 0; auto ptr = st.lower_bound({x, -INF}); if ((*ptr).second < y) { while (true) { --ptr; if ((*ptr).second <= y) { --ptr; int x1 = (*ptr).first; ++ptr; int x2 = (*ptr).first; int y1 = (*ptr).second; ++ptr; int y2 = (*ptr).second; res -= (x2 - x1) * (y1 - y2); --ptr; ptr = st.erase(ptr); } else { break; } } { int x1 = (*ptr).first; ++ptr; int y2 = (*ptr).second; res += (x - x1) * (y - y2); st.emplace(make_pair(x, y)); } } return res; } }; signed main() { cin.tie(0); ios::sync_with_stdio(false); int N; cin >> N; int X[2]; int Y[2]; Solver solver[4]; for (int i = 0; i < N; i++) { cin >> X[0] >> Y[0] >> X[1] >> Y[1]; int res = 0; for (int j = 0; j < 2; j++) { for (int k = 0; k < 2; k++) { res += solver[j * 2 + k].query(abs(X[j]), abs(Y[k])); } } cout << res << "\n"; } return 0; }