Digital Dicitionary Problem

When i am trying samples test cases the code is running fine. But on submiting, TLE error is obtained. Any help is appreciated.