Shopify interview question

An agent navigating through a grid.