Recall the chemistry of acid chloride and carboxylic acid. They react in nucleophilic addition-elimination (condensation) with an alcohol to form an ester.
Amines and amides do not react with alcohols. Amine reacts with an acid chloride.
3 and 4 react with methanol to form the desired product. So the answer is C.