See Problem 8.49
exr:cyk-implementation
