$A \cup B$ and $A \cap B$ connected $\implies A$ and $B$ are connected Let $X$ be a topological space. Let $A$ and $B$ be two subsets of $X$ such that: $A$ and $B$ are closed, $A \cup B$ is connected, $A \cap B$ is connected

Prove that $A$ and $B$ are connected.

Thoughts:
Suppose that $A$ is disconnected. Since $A$ is closed, there are two non-empty, disjoint, closed sets $E$ and $F$ in $X$ such that $A = E \cup F$. Then I attempted many things but all were not really useful.
Please help. Thanks.
 A: Let $X=A\cup B$. Suppose $A$ is disconnected. In particular, $A=C\cup D$ a separation, where $C,D\subset A$ are closed. Thus, they are closed in $X$. Now, consider $A\cap B\subset A$. By a common theorem taught in topology courses, we know $A\cap B\subset C$ or $A\cap B\subset D$, but not both. If $A\cap B\subset C$, then $B\cap D=\emptyset$, so $(B\cup C)\cup D=X$ is a separation. If $A\cap B\subset D$, then $B\cap C=\emptyset$ and $(B\cup D)\cup C=X$ is a separation. Contradiction. So $A$ must be connected.
Hope that helps.
Edit: Suppose $A\cap B\subset C$. Let $x\in B\cap D\subset B\cap A$ since $D\subset A$. But $x\in B\cap A\subset C$ by supposition. But $x\in B\cap D\subset D$. So $x\in C\cap D=\emptyset$ since this is a separation. Contradiction. So $B\cap D=\emptyset$. The other case is equivalent.
A: We may use prove by contrapositive. If $A$ or $B$ is disconnected, with loss of generality, assume $A$ is disconnected. Then by definition, $\exists E, F\not=\emptyset$ such that $A= E\cup F, E\cap F= \emptyset$. Then, $A\cap B= (E\cup F)\cap B=(E\cap B)\cup (F\cap B)$. Notice that $(E\cap B)\cap (F\cap B)=\emptyset$ If  $E\cap B\not=\emptyset$, and $F\cap B\not=\emptyset$, then $A\cap B$ is disconnected. (If $E\cap B=\emptyset$ or $F\cap B\not=\emptyset$, then we just need to continue the process above), then we are done.
