C # program for the above approach
using System ; class GFG { static readonly int row = 6 ; static readonly int col = 7 ; static int [ , ] vis = new int [ row + 1 , col + 1 ] ; static int id ; static int diameter = 0 , length = 0 ; static int x = 0 , y = 0 ;