Let $(X,\mathcal{A},\mu)$ and $(Y,\mathcal{B}, \nu)$ be measure spaces such that $\mu(X)>0$ and $\nu(Y)>0$. Let $f:X \rightarrow \mathbb{R}$ and $g:Y \rightarrow \mathbb{R}$ be measurable functions (with respect to $\mathcal{A}$ and $\mathcal{B}$ respectively) such that $$f(x)=g(y) \text{ $\mu\times\nu$-almost everywhere on $X\times Y$}$$ Show that there exists a constant $\lambda$ such that $f(x)=\lambda$ for $\mu$-a.e. $x$ and $g(y)=\lambda$ for $\nu$-a.e. $y$.
Here is what I was working on: Consider $E = \{ (x,y) : f(x)=g(y) \}$. Then, $\mu \otimes \nu (E^c)=0$. Thus, $$ 0 = \iint_{X \times Y} 1_{E^c} \, d\mu \otimes d\nu = \int_Y \int_X 1_{E^c} \, d\mu \, d\nu,$$ by using Fubini (since $1_{E^c}$ is integrable) or Tonneli (since $1_{E^c}$ is nonnegative). Now, this yields that $\int_X 1_{E^c} \, d\mu = 0$ $\nu$-a.e. Hence, we can pick $y \in Y$ such that $f(x)=g(y)=:\lambda$ $\mu$-a.e. You can do a similar argument to show that $g(y) = \lambda$ $\nu$-a.e.
Now, I realize that I cannot use Fubini or Tonneli unless the measures are $\sigma$-finite, and I haven't used the fact that $\mu(X)>0$ or $\nu(Y)>0$. What am I missing?