JAVA
\nclass Solution {\n    public List<List<Integer>> queensAttacktheKing(int[][] queens, int[] king) {\n        int minb0=Integer.MAX_VALUE,mina0=Integer.MAX_VALU
```\nclass Solution {\n    public List<List<Integer>> queensAttacktheKing(int[][] queens, int[] king) {\n        int minb0=Integer.MAX_VALUE,mina0=Integer.MAX_VALUE,minb1=Integer.MAX_VALUE,mina1=Integer.MAX_VALUE;\n        int minRb=Integer.MAX_VALUE,minRa=Integer.MAX_VALUE,minLb=Integer.MAX_VALUE,minLa=Integer.MAX_VALUE;\n        int arr[]=new int[8];\n        for(int i=0;i<8;i++){\n            arr[i]=queens.length;\n            arr[i]=queens.length;\n        }\n        for(int i=0;i<queens.length;i++){\n            if(king[0]==queens[i][0]){\n                if(king[1]>queens[i][1]){\n                    if(king[1]-queens[i][1]<minb0){\n                        minb0=king[1]-queens[i][1];\n                        arr[0]=i;\n                    }\n                }else{\n                    if(queens[i][1]-king[1]<mina0){\n                        mina0=queens[i][1]-king[1];\n                        arr[1]=i;\n                    }\n                }\n            }else if(king[1]==queens[i][1]){\n                \n                if(king[0]>queens[i][0]){\n                   if(king[0]-queens[i][0]<minb1){\n                        minb1=king[0]-queens[i][0];\n                       arr[2] =i;\n                    }\n                }else{\n                    if(queens[i][0]-king[0]<mina1){\n                        mina1=queens[i][0]-king[0];\n                        arr[3]=i;\n                    }\n                }\n            }else if(king[1]-queens[i][1]==king[0]-queens[i][0]){\n                if(king[0]>queens[i][0]){\n                    if(king[1]-queens[i][1]<minRb){\n                        minRb=king[1]-queens[i][1];\n                        arr[4]=i;\n                    }\n                }else{\n                    if(queens[i][1]-king[1]<minRa){\n                        minRa=queens[i][1]-king[1];\n                        arr[5]=i;\n                    }\n                }\n            }else if(king[1]-queens[i][1]+king[0]-queens[i][0]==0){\n                if(king[1]>queens[i][1]){\n                    if(king[1]-queens[i][1]<minLb){\n                        System.out.println(king[1]-queens[i][1]+"  "+minLb);\n                        minLb=king[1]-queens[i][1];\n                        arr[6]=i;\n                    }\n                }else{\n                    if(queens[i][1]-king[1]<minLa){\n                        minLa=queens[i][1]-king[1];\n                        arr[7]=i;\n                    }\n                }\n            }\n        }\n        List<List<Integer>> op=new ArrayList<List<Integer>>();\n        for(int i=0;i<8;i++){\n            List<Integer> temp=new ArrayList<Integer>();\n            if(arr[i]<queens.length){\n                temp.add(queens[arr[i]][0]);\n                temp.add(queens[arr[i]][1]);\n                op.add(temp);\n            }\n        }\n        return op;\n    }\n}\n```
[]