To find Z one must find X. Finding Y is of no use to find Z.
I get X as:
After addition of $\ce{H2/Pd-C}$, the unsaturated portion becomes saturated and the carboxylic acid remains unchanged.
However I am unsure what does $\ce{H3PO4}$ do to this (new) carboxylic acid? I was unable to find any information. I did find information regarding dehydration with $\ce{P2O5}$, but unsure what to make use out of it.
After looking at (unofficial/3rd party) solutions, I saw that $\ce{H3PO4}$ protonates the $\ce{-OH}$ part of the carboxylic acid (since it is a much stronger acid than the organic acid?) then $\ce{H2O}$ leaves, rendering a carbo-cation at the carbonyl carbon, followed by EAS at the ring.
However, I do not see how $\ce{H3PO4}$ exactly works with the carboxylic acid. I have merely guessed that the $\ce{-OH}$ portion gets protonated (since, this was the only thing I predicted would happen). I really do not know why this happens and how it happens.
Hints and reference material or examples would be appreciated.
The original question is taken from the JEE (Advanced) [2018] Paper-1.