#pragma GCC target("avx2") #pragma GCC optimize("O3") #pragma GCC optimize("unroll-loops") #include using namespace std; int main(){ int N; cin >> N; vector Xa(N), Ya(N), Xb(N), Yb(N); for (int i = 0; i < N; i++){ cin >> Xa[i] >> Ya[i] >> Xb[i] >> Yb[i]; Ya[i] += 20000; Yb[i] += 20000; } vector left(40000, 0), right(40000, 0); for (int i = 0; i < N; i++){ int ans = 0; for (int j = Ya[i]; j < Yb[i]; j++){ if (left[j] > Xa[i]){ ans += left[j] - Xa[i]; left[j] = Xa[i]; } else { break; } } for (int j = Ya[i]; j < Yb[i]; j++){ if (right[j] < Xb[i]){ ans += Xb[i] - right[j]; right[j] = Xb[i]; } else { break; } } for (int j = Yb[i] - 1; j >= Ya[i]; j--){ if (left[j] > Xa[i]){ ans += left[j] - Xa[i]; left[j] = Xa[i]; } else { break; } } for (int j = Yb[i] - 1; j >= Ya[i]; j--){ if (right[j] < Xb[i]){ ans += Xb[i] - right[j]; right[j] = Xb[i]; } else { break; } } cout << ans << endl; } }