The solution lies in the definition of
For any , there is at least one element such that
It also means that for any , there is at least one such that
You can see that this sentence is exactly the definition of a surjection.
Hence is a surjection. By Cantor-Bernstein theorem (I think it's this one), we have
If X is finite, then . So we have . Thus f(X) is finite.
If X is countable, then , etc...
If you see any mistake, tell me, I'm learning this stuff too