Getting TLE after doing a BFS and implementing a trie on H1

Problem :

This is my implementation

I am implementing a BFS to check all reachable states and mapping the states reached in a trie.
But I am unable to get it to run within the time limits. I will be grateful if someone can throw some light on how to improve my code.
here is my code in pastebin for better readability