Funky chess board

import java.util.*;
public class Main {
static class Pair{
int x;int y;
Pair(int x,int y){
this.x=x;this.y=y;
}
}
public static void main(String args[]) {
Scanner sc= new Scanner(System.in);
int n=sc.nextInt();
int a[][]= new int[n][n];
int copy[][]= new int[n][n];
int count=0;
for(int i=0;i<n;i++){
for(int j=0;j<n;j++){
a[i][j]=sc.nextInt();
copy[i][j]=a[i][j];
if(a[i][j]==1){
count++;
}
}}
/if(copy[0][0]==0){
System.out.println(count);
}
/
//else{
Queue q= new LinkedList<>();
q.add(new Pair(0,0));
copy[0][0]=0;
int dx[]= new int[]{2,2,1,1,-1,-1,-2,-2};
int dy[]= new int[]{1,-1,2,-2,2,-2,1,-1};
while(q.size()!=0){
Pair p=q.poll();
for(int i=0;i<8;i++){
int nx=p.x+dx[i];
int ny=p.y+dy[i];
if(nx>=0 && ny>=0 && nx<n && ny<n && copy[nx][ny]==1){
copy[nx][ny]=0;
q.add(new Pair(nx,ny));
}
}
}
count=0;
for(int i=0;i<n;i++){
for(int j=0;j<n;j++){

            if(a[i][j]==1 && copy[i][j]==1){
                count++;
            }
        }}
         System.out.println(count); 
        //}
}

}

wrong ans

Hey Ritika
Would be very happy to help you but can you please reformat the code properly and paste the code on CB IDE and share the link. The code is unintelligible this way.