Context-Free Grammars & Languages

Your answer
Answer & solution
Official answer: C
L1={an bn: n≥0}, nonregular by pumping/distinguishable prefixes. L2=(ab)* is regular. Therefore P false, Q true, C.
Each use of S1→aS1b adds one a and one b at opposite ends; ε stops the derivation. Pumping an a-prefix of ap bp changes only the a count, proving nonregularity. In contrast, S2 repeatedly appends the fixed block ab; a three-state complete DFA can check alternating a,b blocks and reject violations.