#include using namespace std; const int N=50+10,C=300+10,M=1500+10; inline void cmin(int &x,int y) { if (x>y) x=y; } struct L { int s,t,c,m; bool operator < (const L& a) const { return t