For this Question: Given a 2D screen, you are given the location of a pixel in the screen i.e. (x, y) and a color(K), your task is to replace color of the given pixel at (x, y) and all pixels connected to it with the given color K.

Two pixels are connected if these conditions satisfy:
1. They both must have same color
2. They share an edge or they are connected to a common pixel

Example:

{{1, 1, 1, 1, 1, 1, 1, 1},
{1, 1, 1, 1, 1, 1, 0, 0},
{1, 0, 0, 1, 1, 0, 1, 1},
{1, 2, 2, 2, 2, 0, 1, 0},
{1, 1, 1, 2, 2, 0, 1, 0},
{1, 1, 1, 2, 2, 2, 2, 0},
{1, 1, 1, 1, 1, 2, 1, 1},
{1, 1, 1, 1, 1, 2, 2, 1},
 };

 x=4, y=4, color=3 

{{1, 1, 1, 1, 1, 1, 1, 1},
{1, 1, 1, 1, 1, 1, 0, 0},
{1, 0, 0, 1, 1, 0, 1, 1}, 
{1, 3, 3, 3, 3, 0, 1, 0},
{1, 1, 1, 3, 3, 0, 1, 0},
{1, 1, 1, 3, 3, 3, 3, 0},
{1, 1, 1, 1, 1, 3, 1, 1},
{1, 1, 1, 1, 1, 3, 3, 1}, };

Note: Use zero- based indexing.The first line of each test case contains two integers N and M denoting the size of the matrix. Then in the next line are N*M space-separated values of the matrix. Then in the next line are three values x, y and K.

Constraints:
1 <= N, M <= 300
0 <= A[][] <= 100For each test case print the space- separated values of the new matrix.Input:
3 4
0 1 1 0 1 1 1 1 0 1 2 3
0 1 5

Output
0 5 5 0 5 5 5 5 0 5 2 3

Input
2 2
1 1 1 1
0 1 8

Output
8 8 8 8, I have written this Solution Code: import java.io.*;
import java.util.*;

class Point {
	public int x;
	public int y;

	public Point(int xx, int yy) {
		x=xx;
		y=yy;
	}
}


class Main {
	public static void main (String[] args) {
        Scanner in = new Scanner(System.in);
		int n = in.nextInt(), m = in.nextInt();
		int[][] grid = new int[n][m];
		for(int i = 0; i < n; i++) {
			for(int j = 0; j < m; j++) {
				grid[i][j] = in.nextInt();
			}
		}
		int startx = in.nextInt(), starty = in.nextInt();
		int targetColor = in.nextInt();
		int expectedColor = grid[startx][starty];

		Queue<Point> q = new LinkedList<Point>();
        q.add(new Point(startx, starty));
        while(!q.isEmpty()) {
            Point front = q.poll();
            int x = front.x, y = front.y;
			grid[x][y] = targetColor;

			if(x > 0 && grid[x-1][y] == expectedColor) {
				q.add(new Point(x-1, y));
			}
			if(y > 0 && grid[x][y-1] == expectedColor) {
				q.add(new Point(x, y-1));
			}
			if(x < n-1 && grid[x+1][y] == expectedColor) {
				q.add(new Point(x+1, y));
			}
			if(y < m-1 && grid[x][y+1] == expectedColor) {
				q.add(new Point(x, y+1));
			}
        }

		for(int i = 0; i < n; i++) {
			for(int j = 0; j < m; j++) {
				System.out.print(grid[i][j] + " ");
			}
		}
	}
}, In this Programming Language: Java, Now tell me if this Code is compilable or not?