Minho owns N stock products. Each product has K yearly prices recorded in time order.
Minho wants to draw one line graph per product, joining that product's prices in time order, so he can read the price changes at a glance. Giving every product its own chart takes too much space, so he wants to spread all of the graphs over as few charts as possible.
Overlapping or crossing segments make the changes hard to read, so the graphs drawn on one chart must never meet. Two graphs count as overlapping if they touch at even a single point.
Find the smallest number of charts needed to draw the graphs of every stock product under this rule.