Context-Free Grammars & Languages

Answer & solution
Official answer: D
G1 emits any number of initial a symbols, then at least one b, so its language is am bn with m≥0, n>0. G2 chooses an initial a or b, then permits all remaining a symbols before its b symbols; it generates every nonempty am bn and not epsilon. Thus m>0 or n>0, giving D.
In G1 the only way to eliminate S is to enter B, and B has no ε rule, so a b is compulsory. In G2 the first production emits a or b, ruling out ε; after that, ε rules allow stopping. Once a derivation enters B, it emits only b symbols, so neither grammar can place an a after a b. Witnesses distinguish boundaries: b is in both languages, a is in G2 only, and ε is in neither. These tests select the inequalities in D.