Input: N = 9, x = 4, y = 4
mat = {{1, 2, 3, 9, 8, 7, 1, 2, 1}, {4, 5, 6, 1, 2, 3, 7, 9, 8}, {7, 8, 9, 2, 2, 0, 1, 5, 7},
{0, 2, 9, 1, 2, 3, 4, 5, 3}, {9, 8, 7, 4, 5, 6, 7, 4, 1}, {1, 4, 7, 7, 8, 9, 9, 8, 7},
{5, 6, 1, 9, 8, 7, 5, 2, 3}, {4, 5, 1, 6, 5, 4, 9, 7, 4}, {8, 7, 9, 3, 2, 1, 9, 4, 9}},
Output: {{1, 2, 3}, {4, 5, 6}, {7, 8, 9}}
Explanation: Given x = 4, y = 4 that element lies in the middle grid.

Input Matrix
Input: N = 9, x = 6, y= 4
mat = {{1, 2, 3, 9, 8, 7, 1, 2, 1}, {4, 5, 6, 1, 2, 3, 7, 9, 8}, {7, 8, 9, 2, 2, 0, 1, 5, 7},
{0, 2, 9, 1, 2, 3, 4, 5, 3}, {9, 8, 7, 4, 5, 6, 7, 4, 1}, {1, 4, 7, 7, 8, 9, 9, 8, 7},
{5, 6, 1, 9, 8, 7, 5, 2, 3}, {4, 5, 1, 6, 5, 4, 9, 7, 4}, {8, 7, 9, 3, 2, 1, 9, 4, 9}}
Output: {{9, 8, 7}, {6, 5, 4}, {3, 2, 1}}
Explanation: Given x =6, y = 4 that element lies in the grid shown below.

Input Matrix
Below is the implementation of the above approach.