import java.util.*; class Main { public static class Node{ int row; int col; int dist; Node(int row, int col, int dist){ this.row=row; this.col=col; this.dist=dist; } } public static int[][] nearest(int grid[][]){ int n = grid.length; int m = grid[0].length; boolean visited[][]=new boolean[n][m]; int distance[][]=new int[n][m]; Queue q = new LinkedList<>(); for (int i=0; i=0 && newCol >=0 && newRow < n && newCol