We have six positions: 1, 2, 3, 4, 5, 6.
Step 1: Apply the condition on Q and R.
Exactly two people stand between Q and R. This yields two possible patterns:
\[
(Q \_ \_ R), \quad (R \_ \_ Q)
\]
Valid (Q, R) placement pairs are:
(1,4), (2,5), (3,6) and their reverses (4,1), (5,2), (6,3).
Thus, 6 possible placements for the Q–R pair.
Step 2: Apply constraint that P must be ahead of Q.
For each Q–R placement, P must be in a position strictly before Q.
Step 3: Apply restriction on S.
S cannot be adjacent to P, and S cannot be adjacent to R.
This removes invalid choices after P and R are placed.
Step 4: Apply restriction on T.
T cannot be in position 1 or 6.
This further restricts placement once other people are assigned.
Step 5: Enumerate all cases.
We check each Q–R pair systematically:
For (Q,R) = (1,4): P must be in position before 1 → impossible.
For (Q,R) = (2,5): P in (1).
S cannot be adjacent to P (1) and cannot be next to R (5).
After placing T (not 1 or 6) and U, exactly 2 arrangements work.
For (Q,R) = (3,6): P in (1,2).
Applying adjacency restrictions and placing T gives 1 valid arrangement.
Reverse cases:
(Q,R) = (4,1): P must be in (1,2,3).
After restrictions, 1 arrangement remains.
(Q,R) = (5,2): P must be in (1).
After checking adjacency and T’s restriction, 2 arrangements work.
(Q,R) = (6,3): P in (1,2,3,4,5).
Restrictions reduce this to 1 valid arrangement.
Total valid arrangements:
\[
2 + 1 + 1 + 2 + 1 = 7
\]
Final Answer: \(\boxed{7}\)