4. The domain and range of functions $y=f(x), y=g(x)$ are both $R$, and they both have inverse functions, then the inverse function of $y=f^{-1}\left(g^{-1}(f(x))\right)$ is ( ).
(A) $y=f\left(g\left(f^{-1}(x)\right)\right)$
(B) $y=f^{-1}(g(f(x)))$
(C) $y=\int^{-1}\left(g^{-1}(f(x))\right)$
(D) $y=f\left(g^{-1}\left(f^{-1}(x)\right)\right)$
4. (B).

From $y=f^{-1}\left(g^{-1}(f(x))\right)$ we get $g^{-1}(f(x))=f(y)$, and thus, $f(x)=g(f(x))$. Therefore, $x=f^{-1}(g(f(y)))$. By swapping the letters $x$ and $y$, the inverse function of $y=f^{-1}\left(g^{-1}(f(x))\right)$ is $y=f^{-1}(g(f(x)))$.