The P or J letters tells you the type of the first extraverted function.
For example, when you pick the ENTP, the P tells you that the first extraverted function is a perceiving function Pe. So we pick from (NT) the function that is perceiving, which is N. And it is extraverted, therefore Ne.
Now since ENTPs are extroverts, Ne is the first function. Followed by T which will be Ti. Then Fe (not Se, as S has to be a polar opposite of a perceiving function, in this case Ne, so S must be Si, and therefore is the fourth or the inferior function). Also F has to be the polar opposite of the other judging function T. and since T is introverted (Ti) and is the second or auxiliary function; F must be an extroverted function; therefore Fe. As a result, the function stack of the ENTP will become: Ne Ti Fe Si.
Similarly, for INFJs. J implies that their first extroverted function is a judging function Je. So from NF we pick F, and it’s extroverted, so Fe. But the INFJ is introverted, which means that its dominant function must be introverted. As a result, we deduce that of the two major functions of INFJ, which are N and F; the dominant and introverted function is Ni. The polar opposite of the dominant function is Se, and it must be the last function. Similarly, the polar opposite of the auxiliary function Fe is Ti, and it is the third function. Therefore, the function stack of the INFJs will be: Ni Fe Ti Se.