Coffee and Coursework (Hard Version)

CodeForces - 1118D2