An exercise of Mayer-Vietoris sequence. That's the original question:

Let $M$ be a compact manifold without boundary and $U \subset M$ be an open set. Assume that $f: M \rightarrow M$ has $f(M) \subset U$. Using the Mayer-Vietoris sequence, prove that for every $k \in \mathbb{N}$,
$$
\operatorname{tr}\left(f^*: H^k(M) \rightarrow H^k(M)\right)=\operatorname{tr}\left(\left(\left.f\right|_U\right)^*: H^k(U) \rightarrow H^k(U)\right)
$$
where the trace is for the matrix corresponding to the linear mapping.

There seems to be an oversight here, so we also need to assume that $H^*(U)$ is a finite dimensional space.
I guess the professor wants us to use homomorphism between long exact sequence to solve this problem. I think I should use $f$ on a long exact sequence, and then use some knowledge of homology algebra to get the conclusion.
My question is how do I use Mayer-Vietoris sequence to prove this? I don't know how to construct a open cover.

I don't really know why do you need to use Mayer-Vietoris. You have maps
$$
g:M \to U \quad i :U \to M
$$
so $f=i \circ g$, $f_{\mid U}=g \circ i$, and so $f^* = g^*\circ i^*$ and $f_{\mid U}^* = i^* \circ g^*$. Then this just boils down to the fact that $\operatorname{tr}(AB)=\operatorname{tr}(BA)$
