Problem:
You have a museum with a grid layout for its rooms. Each room is of the same size and uniquely numbered. The museum has two gates G1 and G2 – each gate works as an entry and exit point. A person enters through gate G1, walks through each room and then leave through G2. Similarly, a person may enter through gate G2, walk through each room and then leave through G1. To illustrate this with an example, below is a museum with 25 rooms.