void main(){ import std.stdio, std.string, std.conv, std.algorithm; import std.typecons, std.container; int n, m; rd(n, m); auto seq=new Tuple!(int, int)[](m); foreach(i; 0..m){ int d1, d2; string t1, t2; rd(d1, t1, d2, t2); auto st=d1*24*60+to!(int)(t1[0..2])*60+to!(int)(t1[3..$]); auto ed=d2*24*60+to!(int)(t2[0..2])*60+to!(int)(t2[3..$]); seq[i]=Tuple!(int, int)(st, ed); } sort!"a[1]a[1]"); auto sum=0; foreach(e; seq){ while(Q.length>0 && Q.front[1]