static boolean validCube(long[][] a){
        for(int i=0; i<8; i++){
            long[] distance = new long[7];
            int n=0;
            for(int j=0; j<8; j++){
                if(i!=j){
                    distance[n++] = distanceSquare(a, i, j);
                }
            }
            Arrays.sort(distance);
            if(distance[0]==0) return false;
            int[] template = {1,1,1,2,2,2,3};
            for(int j=0; j<7; j++){
                if(distance[j]%distance[0]>0 || template[j]!=distance[j]/distance[0]) return false;
            }
        }
        return true;
    }