```
class Solution {
public:
int computeArea(int A, int B, int C, int D, int E, int F, int G, int H) {
int X1 = max(A,E);
int X2 = min(C,G);
int Y1 = min(D,H);
int Y2 = max(B,F);
int a1 = abs(D-B)*abs(C-A);
int a2 = abs(H-F)*abs(G-E);
if(X2<=X1) return a1+a2;
else{
if(Y2>=Y1) return a1+a2;
else return a1+a2-(abs(Y2-Y1)*abs(X2-X1));
}
}
};
```