Let $f(x) = x^m + a_1x^{m-1} + \cdots+ a_{m-1}x + a_m$ and $g(x) = x^n + b_1x^{n-1} + \cdots + b_{n-1}x + b_n$ be two polynomials with real coefficients such that for each real number $x, f(x)$ is the square of an integer if and only if so is $g(x)$. Prove that if $n +m > 0$, then there exists a polynomial $h(x)$ with real coefficients such that $f(x) \cdot g(x) = (h(x))^2.$

[hide="Remark."]Remark. The original problem stated $g(x) = x^n + b_1x^{n-1} + \cdots + {\color{red}{ b_{n-1}}} + b_n$, but I think the right form of the problem is what I wrote.[/hide]
1. **Define the polynomials and their properties:**
   Let \( f(x) = x^m + a_1x^{m-1} + \cdots + a_{m-1}x + a_m \) and \( g(x) = x^n + b_1x^{n-1} + \cdots + b_{n-1}x + b_n \) be two polynomials with real coefficients. Given that for each real number \( x \), \( f(x) \) is the square of an integer if and only if \( g(x) \) is also the square of an integer.

2. **Behavior of polynomials at large \( x \):**
   Since \( f(x) \) and \( g(x) \) are polynomials, their leading terms dominate as \( x \) becomes large. Specifically, \( f(x) \approx x^m \) and \( g(x) \approx x^n \) for large \( x \). Both polynomials will eventually be positive and increasing if \( m \) and \( n \) are even, or if the leading coefficients are positive.

3. **Identify points where \( f(x) \) and \( g(x) \) are squares of integers:**
   Let \( r \) be a point after which \( f(x) \) is increasing and positive, and similarly, let \( s \) be a point after which \( g(x) \) is increasing and positive. Without loss of generality, assume \( r \geq s \). Thus, for \( x \geq r \), both \( f(x) \) and \( g(x) \) are increasing and positive.

4. **Sequence of points where \( f(x) \) and \( g(x) \) are squares:**
   Define a sequence \( \{r_k\} \) such that \( r < r_n < r_{n+1} < r_{n+2} < \ldots \) and \( f(r_k) = k^2 \) for \( k \geq n \). Since \( g(x) \) must also be a square at these points, let \( g(r_n) = (n+m)^2 \) for some integer \( m \geq -n \). Then, for consistency, \( g(r_{n+1}) = (n+1+m)^2 \), and similarly, \( g(r_{n+k}) = (n+k+m)^2 \) for all \( k \geq 0 \).

5. **Construct the polynomial \( h(x) \):**
   Consider the polynomial \( h(x) = \frac{g(x) + f(x) - m^2}{2} \). We need to show that \( h(x)^2 = f(x) \cdot g(x) \).

6. **Verify the polynomial at specific points:**
   At \( r_k \) for \( k \geq n \),
   \[
   h(r_k) = \frac{g(r_k) + f(r_k) - m^2}{2} = \frac{(k+m)^2 + k^2 - m^2}{2} = \frac{k^2 + 2km + m^2 + k^2 - m^2}{2} = k(k+m).
   \]
   Therefore,
   \[
   h(r_k)^2 = (k(k+m))^2 = k^2(k+m)^2 = f(r_k) \cdot g(r_k).
   \]

7. **Conclusion:**
   Since \( h(x)^2 = f(x) \cdot g(x) \) at an infinite number of points, and both sides are polynomials, they must be identically equal. Thus, \( f(x) \cdot g(x) = h(x)^2 \).

The final answer is \( \boxed{ h(x) = \frac{g(x) + f(x) - m^2}{2} } \).