the dp works for modified CYK