Easy java solution
```\nclass Solution {\n    public int[] findBall(int[][] g) {\n        int k=g.length,p=g[0].length;\n        int a[]=new int[p];\n        for(int i=0;i<p;i++)\
```\nclass Solution {\n    public int[] findBall(int[][] g) {\n        int k=g.length,p=g[0].length;\n        int a[]=new int[p];\n        for(int i=0;i<p;i++)\n        {\n            int m=i,l=0;\n            for(int j=0;j<k;j++)\n            {\n                l=m+g[j][m];\n                if(l<0 || l>=p || g[j][m] != g[j][l])\n                {\n                    m=-1;\n                    break;\n                }\n                m=l;\n            }\n            a[i]=m;\n        }\n        return a;\n    }\n}
['Java']