Formal Language - GATE Exercise 10