The images of two arbitrary functions can partition their domains The source of this problem is from Dugundji's Topology.
Let $f\colon X \to Y$ and $g\colon Y \to X$ be any two maps. Show that $X$ and $Y$ can each be expressed as disjoint unions: $X = X_1 \cup X_2$ and $Y = Y_1 \cup Y_2$, such that $f(X_1) = Y_1$ and $g(Y_2) = X_2$.
I am given a hint: For each $E \subset X$, let $Q(E) = X - g(Y - f(E))$ and take $X_1 = \bigcap \{Q(E) \mid Q(E) \subset E\}$.
My thoughts: I'm thinking if we follow the hint we already have the image $f(X_1) = Y_1$ given to us. Additionally, I am guessing we just define $X_2 = X - X_1$
and $Y_2 = Y - Y_1$ so that everything is partitioned by default, so it seems like the only thing that really needs proving is that $g(X_2) = Y_2$. 
This is where I start getting stuck in an alphabet soup of definitions.
A crazy idea I have (it seems to work in two very simple concrete examples) is that
$X - X_1 = X - \bigcap \{Q(E) \mid Q(E) \subset E\} \color{red}{\stackrel{?}{=}} X - Q(X_1)$
$=X - (X - g(Y - f(Q(X_1))))$
where $x$ is in the final statement if $x \in g(Y - f(Q(X_1))) = g(Y - Y_1) = g(Y_2)$.
I just don't know if the $\color{red}{\stackrel{?}{=}}$ equality holds.
Any help or thoughts would be appreciated.
 A: We have to prove $g(Y_2)=X_2$.

Observe the following:


*

*$Q$ is a monotone operator: if $E\subseteq E'$ then $Q(E)\subseteq Q(E')$.

*$X_1$ itself satisfies $Q(X_1)\subseteq X_1$.


 $X_1\subseteq\bigcap\{E\mid Q(E)\subseteq E\}$ therefore, by 1., $Q(X_1)\subseteq\bigcap\{Q(E)\mid Q(E)\subseteq E\}\,=X_1$.


*If $\,E\subseteq X\,$ is such that $Q(E)\subseteq E$, then $X_1\subseteq Q(E)\subseteq E$, and thus $Y_1=f(X_1)\subseteq f(E)$.


Let $x_2\in X_2\,=X-X_1$, i.e. there is an $E\subseteq X$ with $Q(E)\subseteq E$ such that $x_2\notin Q(E)$. 
Now $x_2\notin Q(E)\,=X-g(Y-f(E))$ means that $x_2\in g(Y-f(E))$, so that there is an $y\in Y-f(E)$ with $g(y)=x_2$. Since $y\notin f(E)$, by the above observation 3., we get $y\notin Y_1$, so $y\in Y_2$.
Conversely, if $y_2\in Y_2\,=Y-f(X_1)$ is given, then let $E:=X_1$, then $g(y_2)\in g(Y-f(E))$, so that $g(y_2)\notin Q(E)$, which - together with observation 2. - shows that $g(y_2)\notin \bigcap\{Q(E)\mid Q(E)\subseteq E\}\ =X_1$, which means $\ g(y_2)\in X_2$.
