'Confused Robot' problem

I am not able to build a logic for this problem

Link - https://csacademy.com/contest/fii-code-2020-round-3/task/confused-robot/statement/

@yuvi2701,
You can checkout the editorial, here.

Why would I have posted a doubt if I understood the editorial !