public long height(Rectangular base) {
        if (cache.containsKey(base)) return cache.get(base);
        long currentHeight = input.get(base), max = currentHeight;
        for (Rectangular rectangular : input.keySet()) {
            if (smaller(base, rectangular)) {
                max = Math.max(max, height(rectangular) + currentHeight);
            }
        }
        return max;
    }