Certain number of persons are sitting in a linear row from west to east and facing in the north direction.
Q sits third from one of the ends. M sits sixth to the right of Q.
Five persons sit between M and X, who is the neighbour of P.

Y sits exactly between M and Q.

The number of persons sitting between X and Y is equal to the number of persons sitting between X and Z.

Three persons sit between P and J, who is fifth from one of the ends. Thus, case 2 is invalid.
Therefore, the final arrangement is:
24 persons can sit in a linear row.