def hizuke(s,t): #日数を1日加算 t+=1 # print(t) t=list(map(int,list(str(t)))) # print(t) if t[2]==6 and t[3]==0: t[2]=0 t[3]=0 t[1]+=1 # t =int("".join(str(t))) if t[0]==2 and t[1]==4: t[0]=0 t[1]=0 s+=1 t=list(map(str,t)) t="".join(t) t=int(t) return (s,t) n,m=map(int,input().split()) lst=[] for i in range(m): d,a,o,b=map(str,input().split()) d=int(d) o=int(o) x=int(a[:2])*100+int(a[3:]) y=int(b[:2])*100+int(b[3:]) lst.append([d,x,o,y]) lst=sorted(lst,key=lambda x:(x[2],x[3],x[0],x[1])) # print(lst) #純粋な日付、時間 tmp=[lst[0][0],lst[0][1],lst[0][2],lst[0][3]] cnt=0 #部屋の稼働室数 after_hizuke=[] for i in range(m):#時間加算後リスト(1分後) tm1,tm2=hizuke ( lst[i][2] , lst[i][3] ) after_hizuke.append([lst[i][0],lst[i][1],tm1,tm2]) # print(after_hizuke) heya=[] # print(heya) for i in range(1,m): tmp3=[] heya_num=len(heya) for j in range(4): # print(after_hizuke[i][j]) # print(i,j) tmp3.append(after_hizuke[i][j]) if heya==[]: heya.append(tmp3) cnt+=1 # print("A:",heya,cnt) elif heya_num>0 and heya_num<=n: for k in range(heya_num): if heya[k][2]