private long getValue(LTuple a, LTuple b) {

        int diffX = a.s.x - a.upLen - b.s.x;
        int diffY = b.s.y + b.rightLen - a.s.y;
        if (diffX >= 0 && diffY >= 0) {
            return (a.upLen - diffX - 1) * (a.rightLen - diffY ) *
                    (b.upLen - diffX) * (b.rightLen - diffY - 1) + 2;
        }
        return -1;
    }